...

/

Inserting Records into Collections

Inserting Records into Collections

Learn how to insert data into MongoDB collections using MeteorJS.

Inserting data into a collection involves putting documents into the MongoDB database. MongoDB doesn’t enforce a schema (a document blueprint for the collection), but it’s important that we structure our documents in ways that reduce the amount of data retrieval code. Later, we’ll write to retrieve data.

Syntax for inserting data

We can insert the data in Meteor.js by writing Mongo.Collection.insert(dataToInsert, callback).

Note: To insert a document, a collection must exist that it can be inserted into.

A callback function has two ...