Saturday 27 May 2017

Use an encrypted file as your database instead of mongodb for your node/express app

How can I use an encrypted file as your database instead of MongoDB or MySQL for your node/express app

where you will give your DB will be of a JSON format and there will be a service that backs it up at regular interval.

It could look like this

{
  "info": {
    "version": "0.0.1",
    "name": "Give your DB a name"
  },
  "data": {

  }
}

and have methods like

myDB.info() // => {"version" : "0.0.2", "name": "demo DB"}

myDB.get('foo'); // => 'bar'

myDB.set('foo', 'bar');

myDB.delete(key);

myDB.backup(function(err) {
    if(err) throw err;
    else console.log('DB backed up at %s', new Date().toString());
});

myDB.search('stats.comments_lookup[{stats.page.id}]', function(res) {
    console.log("search result: ", res);
});

I saw this npm package called express-db but it's outdated and not maintained. Any better option or way of doing this?



via Jalasem

No comments:

Post a Comment