.createCollection()
Creates a new collection where data will be stored in a separate file.
createCollection(name, defaultValues)
Returns
Description
The new collection
const Users = db.createCollection('users');
With default values:
const People = db.createCollection('people', {
name: 'Unnamed person',
hobbies: []
});
With incrementable properties:
Incrementable properties only work with values of type Number.
The Typescript typings for incrementable properties are not yet properly working as of version 2.13.0.
const People = db.createCollection('people', {
$id: 0, // Incrementable property, starting with the value 0
name: 'Unnamed person',
hobbies: []
})
Last updated
Was this helpful?