Files: e9d9dec1d00ff365112ca0f981bbda15e3682528 / test / test-79-npm / levelup / levelup.js
761 bytesRaw
1 | ; |
2 | |
3 | var Levelup = require('levelup'); |
4 | var db = new Levelup('dbname'); |
5 | var 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