db.test.js 922 B

1234567891011121314151617181920212223242526
  1. var database = require("./db.js");
  2. database.init();
  3. // database.put('namezzzzzz', {asd: "gdfhdfh"}, function (err) {
  4. // if (err) return console.log('Ooops!', err) // some kind of I/O error
  5. // // 3) Fetch by key
  6. // database.get('namezzzzzz', function (err, value) {
  7. // if (err) return console.log('Ooops!', err) // likely the key was not found
  8. // // Ta da!
  9. // console.log('name is=' + JSON.stringify(value))
  10. // })
  11. // })
  12. database.put('asdad', {username: "nik"}).
  13. then(() => database.put('asdad2', {username: "nik2"})).
  14. then(() => database.put('asdad3', {username: "nik3"})).
  15. then(() => database.put('asdad4', {username: "nik4"})).
  16. then(() => database.put('asdad5', {username: "nik5"})).then(function(value){
  17. return database.get('naaa');
  18. }).//then(console.log).
  19. then(() => {
  20. database.index.search(['username', 'dimos'])//.on('data', (a) => console.log(a))
  21. .then(console.log);
  22. })
  23. .catch(console.log);