Skip to content
M ABD AZIZ ALFIAN edited this page Nov 3, 2019 · 21 revisions

Welcome to the fly-json-db wiki!

Sorry, We still in progress to update this Wiki.

Getting Started

For the first time, you have no any data, so we going to insert a data first.

const DB = require('fly-json-db');

// example data json array
var data1 = [
  {user_id:1,name:"budi",age:10},
  {user_id:5,name:"wawan",age:20},
  {user_id:3,name:"tono",age:30}
];

// Saving above json array into database
var nosql = new DB();
  nosql.loadArray(data1).then(data => {
    nosql.save('path/to/file.nosql').then(data => {
      console.log(data);
    });
  });

API

loadArray(array, callback)

Load an array into odm.

  • array - this is the json array.
  • callback(error, data) - If you are not using callback, then will return promise. [optional]

Example

nosql.loadArray(data1).then(data => {
  console.log(nosql.odm.exec());
}, error => {
  console.log(error);
});
Clone this wiki locally