SDK
SDK Dart Null Safety v3.x
2

create #

Creates a new collection in Kuzzle via the persistence engine, in the provided index.

You can also provide an optional data mapping that allows you to exploit the full capabilities of our persistent data storage layer, ElasticSearch (check here the mapping capabilities of ElasticSearch).

This method will only update the mapping if the collection already exists.



Arguments #

Future<Map<String, dynamic>> create(
    String index,
    String collection, {
    Map<String, dynamic> mapping = const {},
  })
ArgumentsTypeDescription
index
String
Index
collection
String
Collection
mapping
Map<String, dynamic>

({})
Describes the data mapping to associate to the new collection, using Elasticsearch mapping format

mapping #

A Map<String, dynamic> representing the data mapping of the collection.

The mapping must have a root field properties that contain the mapping definition:

More information about database mappings here.

Usage #

await kuzzle
  .collection
  .create(
    'nyc-open-data',
    'yellow-taxi',
    mapping: <String, dynamic>{
  'properties': <String, dynamic>{
    'license': <String, dynamic>{
      'type': 'keyword',
    },
  },
});