SDK
SDK Dart v2.x
2

create #

Creates a new document in the persistent data storage.

Throws an error if the document already exists.

The optional parameter waitForRefresh can be used with the value true in order to wait for the document to be indexed (indexed documents are available for search).


Arguments #

Future<Map<String, dynamic>> create(
    String index,
    String collection,
    Map<String, dynamic> document, {
    String id,
    bool waitForRefresh = false,
  })
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
document
Map<String, dynamic>
Document content
id
String

(null)
Document id
waitForRefresh
bool

(false)
If set to true, Kuzzle will wait for the persistence layer to finish indexing

Return #

A Map<String, dynamic> which has the following properties:

PropertyTypeDescription
_source
Map<String, dynamic>
Created document
_id
String
ID of the newly created document
_version
int
Version of the document in the persistent data storage

Usage #

final result = await kuzzle
  .document
  .create(
    'nyc-open-data',
    'yellow-taxi',
    {
      'firstname': 'John'
    },
  );