@@ -8,15 +8,15 @@ const Readable = require('readable-stream')
8
8
const replaceAll = ( str , search , replacement ) => str . toString ( ) . split ( search ) . join ( replacement )
9
9
10
10
class DocumentStore extends Store {
11
- constructor ( ipfs , id , dbname , options ) {
11
+ constructor ( ipfs , id , dbname , options ) {
12
12
if ( ! options ) options = { }
13
13
if ( ! options . indexBy ) Object . assign ( options , { indexBy : '_id' } )
14
14
if ( ! options . Index ) Object . assign ( options , { Index : DocumentIndex } )
15
15
super ( ipfs , id , dbname , options )
16
16
this . _type = 'docstore'
17
17
}
18
18
19
- get ( key , caseSensitive = false ) {
19
+ get ( key , caseSensitive = false ) {
20
20
key = key . toString ( )
21
21
const terms = key . split ( ' ' )
22
22
key = terms . length > 1 ? replaceAll ( key , '.' , ' ' ) . toLowerCase ( ) : key . toLowerCase ( )
@@ -37,16 +37,16 @@ class DocumentStore extends Store {
37
37
. map ( mapper )
38
38
}
39
39
40
- query ( mapper , options = { } ) {
40
+ query ( mapper , options = { } ) {
41
41
// Whether we return the full operation data or just the db value
42
42
const fullOp = options ? options . fullOp : false
43
43
44
44
return Object . keys ( this . _index . _index )
45
45
. map ( ( e ) => this . _index . get ( e , fullOp ) )
46
- . filter ( ( e ) => mapper ( e ) )
46
+ . filter ( mapper )
47
47
}
48
48
49
- batchPut ( docs , onProgressCallback ) {
49
+ batchPut ( docs , onProgressCallback ) {
50
50
const mapper = ( doc , idx ) => {
51
51
return this . _addOperationBatch (
52
52
{
@@ -64,7 +64,7 @@ class DocumentStore extends Store {
64
64
. then ( ( ) => this . saveSnapshot ( ) )
65
65
}
66
66
67
- put ( doc ) {
67
+ put ( doc ) {
68
68
if ( ! doc [ this . options . indexBy ] )
69
69
throw new Error ( `The provided document doesn't contain field '${ this . options . indexBy } '` )
70
70
@@ -75,7 +75,7 @@ class DocumentStore extends Store {
75
75
} )
76
76
}
77
77
78
- del ( key ) {
78
+ del ( key ) {
79
79
if ( ! this . _index . get ( key ) )
80
80
throw new Error ( `No entry with key '${ key } ' in the database` )
81
81
0 commit comments