I tried NeDB in node-webkit it's working fine on in memory data but not able to store in persistent storage.
definitely no node-webkit or nedb expert but this is how I did it and it worked.
As already mentioned by mvanderw in the comments, definitely make sure to check the autoload option.
This is for example my configuration for a simple node-webkit/ angular todo app:
var Datastore = require('nedb'),
path = require('path'),
db = new Datastore({ filename: path.join(require('nw.gui').App.dataPath, 'todo.db'), autoload: true });
When I restart the app, all todos are still there and I'm ready to go.
Hope this helps
Edit: Example as requested by Scott
var Datastore = require('nedb'),
path = require('path'),
db = new Datastore({
filename:path.join(require('nw.gui').App.dataPath, 'todo.db'),
autoload: true
});
var todoServices = angular.module('todoServices', []);
todoServices.factory('Todo', function($q) {
return {
getAll: function(){
var defer = $q.defer();
db.find({
//...some criteria
},
function(err, docs) {
defer.resolve(docs);
});
return defer.promise;
}, //...moar code
}
});
Something like this...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With