.create()

Creates and pushes a new entry into the collection.

create(data)

Parameter

Description

data

Data

Entry's data

Returns

Description

The newly created entry

// Note: People is a collection.
// This collection was created with a default value of 900 for the 'salary' key.

People.create({ id: 1, name: 'Peter', salary: 1200 }); // { id: 1, name: 'Peter', salary: 1200 }
People.create({ id: 2, name: 'Michael' }); // { id: 2, name: 'Michael', salary: 900 }

People.getAll();  // [{ id: 1, name: 'Peter', salary: 1200 }, { id: 2, name: 'Michael', salary: 900 }] 

Last updated