SDK
SDK Dart Null Safety v3.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 #

Copied to clipboard!
Future<Map<String, dynamic>> create(
    String index,
    String collection,
    Map<String, dynamic> document, {
    String id,
    bool waitForRefresh = false,
  })
Arguments Type Description
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:

Property Type Description
_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 #

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