git ssb

0+

cel-desktop / ssb-pkg



Tree: ca90b5ca0579ebdcc0635288bce4978e3fb200f5

Files: ca90b5ca0579ebdcc0635288bce4978e3fb200f5 / test / test-79-npm / levelup / levelup.js

761 bytesRaw
1'use strict';
2
3var Levelup = require('levelup');
4var db = new Levelup('dbname');
5var rimraf = require('../../../node_modules/rimraf');
6
7(function (cb) {
8 db.open(function (error1) {
9 if (error1) return cb(error1);
10
11 db.put('dave@gmail.com', JSON.stringify({
12 _id: 'dave@gmail.com',
13 name: 'David',
14 age: 68
15 }), function (error2) {
16 if (error2) return cb(error2);
17 db.get('dave@gmail.com', function (error3, data) {
18 if (error3) return cb(error3);
19 data = JSON.parse(data.toString());
20 if (data.age === 68) {
21 console.log('ok');
22 return cb();
23 }
24 });
25 });
26 });
27}(function (error) {
28 if (error) throw error;
29 db.close(function () {
30 rimraf.sync('dbname');
31 });
32}));
33

Built with git-ssb-web