1
1
var level = require ( 'level' )
2
+ var hypercore = require ( 'hypercore' )
2
3
3
4
var hyperkv = require ( 'hyperkv' )
4
5
var hyperlog = require ( 'hyperlog' )
5
6
var sub = require ( 'subleveldown' )
6
7
7
- // var createImportPipeline = require('./lib/import.js')
8
+ var createImportPipeline = require ( './lib/import.js' )
9
+ var importRowKv = require ( './lib/importkv.js' )
8
10
var addRow = require ( './lib/add.js' )
9
11
var deleteRow = require ( './lib/delete.js' )
10
12
11
13
module . exports = Jawn
12
14
13
15
function Jawn ( opts ) {
14
16
if ( ! opts ) opts = { }
17
+ this . core = initializeHypercore ( opts )
15
18
this . kv = initializeHyperkv ( opts )
16
19
this . db = this . core . db
20
+ this . db_kv = this . kv . db
17
21
}
18
22
19
- /*
20
23
Jawn . prototype . createImportPipeline = function ( opts ) {
21
24
return createImportPipeline ( this , opts )
22
25
}
23
- */
26
+
27
+ Jawn . prototype . importRowKv = function ( file ) {
28
+ return importRowKv ( this , file )
29
+ }
24
30
25
31
Jawn . prototype . addRow = function ( key , value ) {
26
32
return addRow ( this , key , value )
@@ -34,6 +40,17 @@ Jawn.prototype.deleteRow = function (key) {
34
40
// @default Creates a leveldb database called `data.jawn` and initializes hypercore using that db
35
41
// @option 'core' the hypercore instance to use
36
42
// @option 'db' the db instace (leveldb) to initialize hypercore with. This is ignored if you use the `core` option
43
+ function initializeHypercore ( opts ) {
44
+ var core
45
+ if ( opts . hasOwnProperty ( 'core' ) ) {
46
+ core = opts . core
47
+ } else {
48
+ var db = opts . db || level ( 'data.jawn' )
49
+ core = hypercore ( db )
50
+ }
51
+ return core
52
+ }
53
+
37
54
function initializeHyperkv ( opts ) {
38
55
var kv
39
56
if ( opts . hasOwnProperty ( 'core' ) ) {
0 commit comments