This method can be used to insert a json object/document into a collection. It accepts an array of json objects (so you can insert one or many documents into a collection with single function call). It returns the ids of inserted documents in response (we automatically assign a unique id to each document before actually inserting it into the datastore - primary key). It accepts following arguments

documentsarrayan array of json objects

This method returns following codes


empty array is provided or collection name wasn't specified while getting the reference


documents has been inserted successfully


failed to insert the documents into the collection

The usage of this method is illustrated in the example below

// Define an array of json objects
var documents = [{
  voltage: 20,
  current: 2
// Insert document into a collection
collection.insert(documents).then((res) => {
  // Got response from server
  switch(res.code) {
      // Methods returns the unique ids of each
      // inserted document