@@ -22,25 +22,25 @@ class Datastore extends EventEmitter {
22
22
*/
23
23
24
24
constructor ( {
25
- filename,
26
- autoload,
25
+ filename,
26
+ autoload,
27
27
timeStamp,
28
28
bufSize
29
- } : DataStoreOptions ) {
29
+ } : DataStoreOptions ) {
30
30
super ( ) ;
31
31
this . filename = filename ? resolve ( Deno . cwd ( ) , filename ) : resolve ( Deno . cwd ( ) , "./database.json" ) ;
32
32
this . bufSize = bufSize ;
33
33
if ( autoload ) this . loadDatabase ( ) . then ( ( ) => {
34
34
this . emit ( 'load' )
35
- } )
35
+ } )
36
36
} ;
37
37
38
38
/**
39
39
* Loads the database on first load and ensures that path exists.
40
40
* @method
41
41
*/
42
42
43
- async loadDatabase ( ) {
43
+ async loadDatabase ( ) {
44
44
return init ( this . filename )
45
45
}
46
46
@@ -53,7 +53,7 @@ class Datastore extends EventEmitter {
53
53
* @return Promise
54
54
*/
55
55
56
- async find ( query : { any : any } , projection : any = { } , cb : ( x : any ) => any ) {
56
+ async find ( query : { any : any } , projection : any = { } , cb ? : ( x : any ) => any ) {
57
57
if ( cb && typeof cb == 'function' ) return cb ( await this . executor . add ( _find , [ this . filename , query , projection , this . bufSize ] ) ) ;
58
58
return this . executor . add ( _find , [ this . filename , query , projection , this . bufSize ] )
59
59
}
@@ -67,7 +67,7 @@ class Datastore extends EventEmitter {
67
67
* @return Promise
68
68
*/
69
69
70
- async findOne ( query : { any : any } , projection : any = { } , cb : ( x : any ) => any ) {
70
+ async findOne ( query : { any : any } , projection : any = { } , cb ? : ( x : any ) => any ) {
71
71
projection = projection || { } ;
72
72
if ( cb && typeof cb == 'function' ) return cb ( await this . executor . add ( _findOne , [ this . filename , query , projection , this . bufSize ] ) ) ;
73
73
return this . executor . add ( _findOne , [ this . filename , query , projection , this . bufSize ] )
@@ -81,7 +81,7 @@ class Datastore extends EventEmitter {
81
81
* @return Promise
82
82
*/
83
83
84
- async insert ( data : any , cb : ( x : any ) => any ) {
84
+ async insert ( data : any , cb ? : ( x : any ) => any ) {
85
85
if ( cb && typeof cb == 'function' ) cb ( await this . executor . add ( _insert , [ this . filename , data ] ) )
86
86
return this . executor . add ( _insert , [ this . filename , data ] )
87
87
}
@@ -95,7 +95,7 @@ class Datastore extends EventEmitter {
95
95
* @return Promise
96
96
*/
97
97
98
- async update ( query : { any : any } , operators : any , cb : ( x : any ) => any ) {
98
+ async update ( query : { any : any } , operators : any , cb ? : ( x : any ) => any ) {
99
99
if ( cb && typeof cb == "function" ) return cb ( await this . executor . add ( _update , [ this . filename , query , operators , this . bufSize ] ) ) ;
100
100
return this . executor . add ( _update , [ this . filename , query , operators , this . bufSize ] )
101
101
}
@@ -109,7 +109,7 @@ class Datastore extends EventEmitter {
109
109
* @return Promise
110
110
*/
111
111
112
- async updateOne ( query : { any : any } , operators : any , cb : ( x : any ) => any ) {
112
+ async updateOne ( query : { any : any } , operators : any , cb ? : ( x : any ) => any ) {
113
113
if ( cb && typeof cb == "function" ) return cb ( await this . executor . add ( _updateOne , [ this . filename , query , operators , this . bufSize ] ) ) ;
114
114
return this . executor . add ( _updateOne , [ this . filename , query , operators , this . bufSize ] )
115
115
}
@@ -122,7 +122,7 @@ class Datastore extends EventEmitter {
122
122
* @return Promise
123
123
*/
124
124
125
- async remove ( query : any , cb : ( x : any ) => any ) {
125
+ async remove ( query : any , cb ? : ( x : any ) => any ) {
126
126
if ( cb && typeof cb == "function" ) return cb ( await this . executor . add ( _remove , [ this . filename , query , this . bufSize ] ) ) ;
127
127
return this . executor . add ( _remove , [ this . filename , query , this . bufSize ] )
128
128
}
@@ -135,12 +135,12 @@ class Datastore extends EventEmitter {
135
135
* @return Promise
136
136
*/
137
137
138
- async removeOne ( query : any , cb : ( x : any ) => any ) {
138
+ async removeOne ( query : any , cb ? : ( x : any ) => any ) {
139
139
if ( cb && typeof cb == "function" ) return cb ( await this . executor . add ( _removeOne , [ this . filename , query , this . bufSize ] ) ) ;
140
140
return this . executor . add ( _removeOne , [ this . filename , query , this . bufSize ] )
141
141
}
142
142
143
- }
143
+ }
144
144
145
145
export { Datastore }
146
146
0 commit comments