var parse = require('./js/parse');
var Datastore = require('nedb');
var db = new Datastore({
  filename: `${__dirname}/tasks.db`,
  autoload: true
});

/**
 * Get a query, parse it and add it to
 * database
 * @param {string} query task query
 */
function addToDB(query) {
  console.log('Enter');
  try {
    var taskObj = parse(query);
    db.insert(taskObj, (err, data) => {
      if(err) {
        console.log(err);
      } else {
        console.log(data);
      }
    });
  } catch (e) {
    console.log(e);
  }
}

angular.module('MainApp')
  .factory('addToDB', () => {
    return addToDB;
  });

@@ -24,24 +24,92 @@
 js/parse');%0A
+const crypto = require('crypto');%0Aconsole.log(crypto.createCipher);%0A
 var Datastor
@@ -191,16 +191,380 @@
 ks.db%60,%0A
+  afterSerialization: (object) =%3E %7B%0A    var cipher = crypto.createCipher('aes256', 'sample-key');%0A    return (cipher.update(object, 'utf8', 'hex') + cipher.final('hex'));%0A  %7D,%0A  beforeDeserialization: (object) =%3E %7B%0A    var decipher = crypto.createDecipher('aes256', 'sample-key');%0A    return (decipher.update(object, 'hex', 'utf8') + decipher.final('utf8'));%0A  %7D,%0A
   autolo

Add basic encryption for database