test.js 495 B

1234567891011121314151617181920
  1. var level = require('level');
  2. var path = require('path');
  3. var DIR = path.dirname(__filename);
  4. // 1) Create our store
  5. var db = level(DIR + './mydb')
  6. // 2) Put a key & value
  7. db.put('name', 'Level', function (err) {
  8. if (err) return console.log('Ooops!', err) // some kind of I/O error
  9. // 3) Fetch by key
  10. db.get('name', function (err, value) {
  11. if (err) return console.log('Ooops!', err) // likely the key was not found
  12. // Ta da!
  13. console.log('name=' + value)
  14. })
  15. });
  16. // let db;