-
Notifications
You must be signed in to change notification settings - Fork 0
Home
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.
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);
});
});
- ODM - This is an Object Document Mapper for json.
- loadArray(array, callback) - Load an array into odm.
- loadFile(filePath, callback) - Load json from file into odm.
- joinArray(array, name, callback) - Load an array data for join into odm.
- joinFile(filePath, name, callback) - Load json from file for join into odm.
- save(filePath, callback) - Save odm result into file.
- drop(filePath, callback) - Drop or delete file json.
This is an Object Document Mapper for json.
We use fly-json-odm for CRUD
, Query
, Join
and Transform
support. Please see their documentation on Wiki.
Example:
nosql.loadArray(data1).then(data => {
// start query
var result = nosql.odm.select(['user_id','name','age']).where('age','>',10).exec();
console.log(result);
});
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);
});