SDK
SDK Dart Null Safety v3.x
2

mCreateOrReplace #

Creates or replaces multiple documents.


Arguments #

Future<Map<String, dynamic>> mCreateOrReplace(
    String index,
    String collection,
    List<Map<String, dynamic>> documents, {
    bool waitForRefresh = false,
  })
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
documents
List<Map<String, dynamic>>
List containing the documents to create
waitForRefresh
bool
If set to true, Kuzzle will wait for the persistence layer to finish indexing

documents #

Each document has the following properties:

ArgumentsTypeDescription
_id
String
Optional document ID. Will be auto-generated if not defined.
body
Map<String, dynamic>
Document body

Return #

A Map<String, dynamic> which has a successes and errors: Each created document is an object of the successes array with 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

Each errored document is an object of the errors array with the following properties:

PropertyTypeDescription
document
Map<String, dynamic>
Document that causes the error
status
int
HTTP error status
reason
String
Human readable reason

Usage #

final result = await kuzzle
  .document
  .mCreateOrReplace("nyc-open-data", "yellow-taxi", [
    {
      '_id': 'some-id',
      'body': {
        'Agent': 'Smith'
      }
    },
    {
      '_id': 'some-id2',
      'body': {
        'Gordon': 'Freeman'
      }
    }
  ]);