@@ -29,6 +29,7 @@ import {
29
29
getFromMapOrThrow ,
30
30
lastOfArray ,
31
31
now ,
32
+ PROMISE_RESOLVE_TRUE ,
32
33
PROMISE_RESOLVE_VOID ,
33
34
RX_META_LWT_MINIMUM
34
35
} from '../../util' ;
@@ -65,8 +66,8 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
65
66
> {
66
67
67
68
public readonly primaryPath : StringKeys < RxDocumentData < RxDocType > > ;
68
- private changes$ : Subject < EventBulk < RxStorageChangeEvent < RxDocumentData < RxDocType > > , RxStorageDefaultCheckpoint > > = new Subject ( ) ;
69
69
public closed = false ;
70
+ private changes$ : Subject < EventBulk < RxStorageChangeEvent < RxDocumentData < RxDocType > > , RxStorageDefaultCheckpoint > > = new Subject ( ) ;
70
71
71
72
constructor (
72
73
public readonly storage : RxStorageMemory ,
@@ -167,7 +168,7 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
167
168
return Promise . resolve ( ret ) ;
168
169
}
169
170
170
- async findDocumentsById (
171
+ findDocumentsById (
171
172
docIds : string [ ] ,
172
173
withDeleted : boolean
173
174
) : Promise < RxDocumentDataById < RxDocType > > {
@@ -187,7 +188,7 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
187
188
return Promise . resolve ( ret ) ;
188
189
}
189
190
190
- async query ( preparedQuery : MemoryPreparedQuery < RxDocType > ) : Promise < RxStorageQueryResult < RxDocType > > {
191
+ query ( preparedQuery : MemoryPreparedQuery < RxDocType > ) : Promise < RxStorageQueryResult < RxDocType > > {
191
192
const queryPlan = preparedQuery . queryPlan ;
192
193
const query = preparedQuery . query ;
193
194
const skip = query . skip ? query . skip : 0 ;
@@ -261,12 +262,12 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
261
262
// apply skip and limit boundaries.
262
263
rows = rows . slice ( skip , skipPlusLimit ) ;
263
264
264
- return {
265
+ return Promise . resolve ( {
265
266
documents : rows
266
- } ;
267
+ } ) ;
267
268
}
268
269
269
- async getChangedDocumentsSince (
270
+ getChangedDocumentsSince (
270
271
limit : number ,
271
272
checkpoint ?: RxStorageDefaultCheckpoint
272
273
) : Promise < {
@@ -306,7 +307,7 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
306
307
}
307
308
308
309
const lastDoc = lastOfArray ( rows ) ;
309
- return {
310
+ return Promise . resolve ( {
310
311
documents : rows ,
311
312
checkpoint : lastDoc ? {
312
313
id : lastDoc [ this . primaryPath ] as any ,
@@ -315,10 +316,10 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
315
316
id : '' ,
316
317
lwt : 0
317
318
}
318
- } ;
319
+ } ) ;
319
320
}
320
321
321
- async cleanup ( minimumDeletedTime : number ) : Promise < boolean > {
322
+ cleanup ( minimumDeletedTime : number ) : Promise < boolean > {
322
323
const maxDeletionTime = now ( ) - minimumDeletedTime ;
323
324
const index = [ '_deleted' , '_meta.lwt' , this . primaryPath as any ] ;
324
325
const indexName = getMemoryIndexName ( index ) ;
@@ -357,7 +358,7 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
357
358
indexOfLower ++ ;
358
359
}
359
360
}
360
- return true ;
361
+ return PROMISE_RESOLVE_TRUE ;
361
362
}
362
363
363
364
getAttachmentData ( documentId : string , attachmentId : string ) : Promise < string > {
@@ -384,12 +385,12 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
384
385
await this . close ( ) ;
385
386
}
386
387
387
- async close ( ) : Promise < void > {
388
+ close ( ) : Promise < void > {
388
389
if ( this . closed ) {
389
- throw newRxError ( 'SNH' , {
390
+ return Promise . reject ( newRxError ( 'SNH' , {
390
391
database : this . databaseName ,
391
392
collection : this . collectionName
392
- } ) ;
393
+ } ) ) ;
393
394
}
394
395
this . closed = true ;
395
396
this . changes$ . complete ( ) ;
@@ -400,6 +401,8 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
400
401
getMemoryCollectionKey ( this . databaseName , this . collectionName )
401
402
) ;
402
403
}
404
+
405
+ return PROMISE_RESOLVE_VOID ;
403
406
}
404
407
405
408
conflictResultionTasks ( ) : Observable < RxConflictResultionTask < RxDocType > > {
@@ -410,7 +413,7 @@ export class RxStorageInstanceMemory<RxDocType> implements RxStorageInstance<
410
413
}
411
414
}
412
415
413
- export async function createMemoryStorageInstance < RxDocType > (
416
+ export function createMemoryStorageInstance < RxDocType > (
414
417
storage : RxStorageMemory ,
415
418
params : RxStorageInstanceCreationParams < RxDocType , RxStorageMemoryInstanceCreationOptions > ,
416
419
settings : RxStorageMemorySettings
@@ -442,5 +445,5 @@ export async function createMemoryStorageInstance<RxDocType>(
442
445
params . options ,
443
446
settings
444
447
) ;
445
- return instance ;
448
+ return Promise . resolve ( instance ) ;
446
449
}
0 commit comments