arvindr21 / diskDB

A Lightweight Disk based JSON Database with a MongoDB like API for Node
http://arvindr21.github.io/diskDB
603 stars 65 forks source link

Save Error #35

Open skmani opened 7 years ago

skmani commented 7 years ago

hi i am new to this development. i am using diskdb for saving data. it works fine but when i close the app and reopen, all data disappears seems not saved in JSON file. anyone please help me.

patchfx commented 7 years ago

@skmani Are you able to replicate through a small snippet of code? Does the db file get removed when the app/server is stopped? Or does it persist? Is the path always the same?

skmani commented 7 years ago

Thanks for Your response.

DB file exist with default data and the path always tha same.

Here is the code: dash.addUser = function(id,name,wname,fname,mname,address,city,pincd,dist,state) {

var refidfrm = db.users.count() + 1;

if (db.users.findOne({
    id: id
})) return 0; 
// save the user to DB
var savedUser = db.users.save({
    refid: refidfrm,
    id: id,
    name: name,
    wifename: wname,
    fathername: fname,
    mothername: mname,
    address: address,
    city: city,
    pincode: pincd,
    district: dist,
    state: state
});
return 1; 

};

When i run the application in developermode it works fine after packing the application i find this problem.