See how to use the NEDB Total.js using the definitions

168 views
Skip to first unread message

Felipo Antonoff

unread,
Feb 21, 2014, 8:49:48 PM2/21/14
to tot...@googlegroups.com
NEDB is a database SQLite data type, used a similar API with MongoDB, I'll use in my new project, below is a short guide on how to use it in Total.js

Using NEDB with total.js first instalale and adds it to your project with this command:
sudo npm install nedb --save

In /definitions/ creates a file called nedb.js or name you prefer and paste it

// sudo npm install nedb --save
var Datastore = require('nedb')
  , db = new Datastore({ filename: '/path/file', autoload: true });
global.db = db;

Within a function of control put this to test
db.insert([{ a: 'Teste ok' }, { b: 'Teste 2 ok' }], function (err, newDocs) {
  // Two documents were inserted in the database
  // newDocs is an array with these documents, augmented with their _id
});
self.plain('Dados inseridos');

Run the application node index.js, go to the url and then goes in the path of the database file and see if the date is :), you can now play with NEDB, see more details here https://github.com/louischatriot/nedb

Peter Širka

unread,
Feb 22, 2014, 3:51:18 AM2/22/14
to tot...@googlegroups.com
Hi Felipo,
can you write a small (full) example? I'll add your example into total.js examples.

Thanks.
Reply all
Reply to author
Forward
0 new messages