UNPKG

798 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var base = require('./base.js');
4
5// base() creates a leveldb and a level-tree-index with some test data
6// the callback deletes the database
7base(function(err, db, tree, cb) {
8 if(err) return cb(err);
9
10 console.log("parent:", tree.parentPathFromPath('foo.bar.baz'));
11
12 tree.parentFromPath('foo.bar.baz', function(err, key, value) {
13 if(err) return cb(err);
14
15 console.log("parent of baz: key:", key, "value:", value);
16
17 tree.parentFromPath('foo', function(err, key, value) {
18 if(err) return cb(err);
19
20 console.log("parent of foo: key:", key, "value:", value);
21
22 tree.parentPathFromValue({}, function(err, path) {
23 if(err) return cb(err);
24
25 console.log("parent path of foo:", path);
26
27 cb();
28 });
29 });
30 });
31});
32