SDK
SDK Dart Null Safety v3.x
2

createOrReplace #

Creates a new document in the persistent data storage, or replaces its content if it already exists.


Arguments #

Future<Map<String, dynamic>> createOrReplace(
    String index,
    String collection,
    String id,
    Map<String, dynamic> document, {
    bool waitForRefresh = false,
  })
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
id
String
Document ID
document
Map<String, dynamic>
Document content
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>
Document content
_id
String
ID of the document
_version
int
Version of the document in the persistent data storage

Usage #

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