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,
})
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 #
final result = await kuzzle
.document
.create(
'nyc-open-data',
'yellow-taxi',
{
'firstname': 'John'
},
);
Edit this page on Github(opens new window)