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