Files: 65191f9a9664f013ebe726bb95a1a54b086e1bd5 / test / test-79-npm / leveldown / leveldown.js
767 bytesRaw
1 | ; |
2 | |
3 | var Leveldown = require('leveldown'); |
4 | var db = new Leveldown('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