@@ -154,8 +154,8 @@ Ground.Collection = class GroundCollection {
154
154
Kernel . defer ( ( ) => {
155
155
156
156
// Add the document to minimongo
157
- if ( ! this . _collection . _docs . _map [ id ] ) {
158
- this . _collection . _docs . _map [ id ] = EJSON . fromJSONValue ( doc ) ;
157
+ if ( ! this . _collection . _docs . _map . has ( id ) ) {
158
+ this . _collection . _docs . _map . set ( [ id ] , EJSON . fromJSONValue ( doc ) ) ;
159
159
160
160
// Invalidate the observers pr. document
161
161
// this call is throttled
@@ -221,9 +221,9 @@ Ground.Collection = class GroundCollection {
221
221
setDocument ( doc , remove ) {
222
222
doc . _id = strId ( doc . _id ) ;
223
223
if ( remove ) {
224
- delete this . _collection . _docs . _map [ doc . _id ] ;
224
+ this . _collection . _docs . _map . remove ( doc . _id ) ;
225
225
} else {
226
- this . _collection . _docs . _map [ doc . _id ] = EJSON . clone ( doc ) ;
226
+ this . _collection . _docs . _map . set ( doc . _id , EJSON . clone ( doc ) ) ;
227
227
}
228
228
this . invalidate ( ) ;
229
229
}
@@ -328,7 +328,7 @@ Ground.Collection = class GroundCollection {
328
328
329
329
clear ( ) {
330
330
this . storage . clear ( ) ;
331
- this . _collection . _docs . _map = { } ;
331
+ this . _collection . _docs . _map . clear ( )
332
332
this . invalidate ( ) ;
333
333
}
334
334
@@ -339,14 +339,15 @@ Ground.Collection = class GroundCollection {
339
339
keep ( cursors ) {
340
340
const arrayOfCursors = ( Array . isArray ( cursors ) ) ? cursors : [ cursors ] ;
341
341
// Map the ground db storage into an array of id's
342
- const currentIds = Object . keys ( this . _collection . _docs . _map ) ;
342
+ let currentIds = this . _collection . _docs . _map . keys ( )
343
+ currentIds = Array . from ( currentIds ) ;
343
344
// Map each cursor id's into one flat array
344
345
const keepIds = arrayOfCursors . map ( ( cursor ) => cursor . map ( ( doc ) => strId ( doc . _id ) ) ) . flat ( ) ;
345
346
// Remove all other documents from the collection
346
347
const arrays = [ currentIds , keepIds ] ;
347
348
for ( const id of arrays . reduce ( ( a , b ) => a . filter ( ( c ) => ! b . includes ( c ) ) ) ) {
348
349
// Remove it from in memory
349
- delete this . _collection . _docs . _map [ id ] ;
350
+ this . _collection . _docs . _map . delete ( id )
350
351
// Remove it from storage
351
352
this . saveDocument ( { _id : id } , true ) ;
352
353
}
@@ -355,7 +356,7 @@ Ground.Collection = class GroundCollection {
355
356
}
356
357
357
358
toJSON ( ) {
358
- return JSON . stringify ( this . _collection . _docs . _map ) ;
359
+ return JSON . stringify ( Object . fromEntries ( this . _collection . _docs . _map . entries ( ) ) )
359
360
}
360
361
361
362
// Simulate the Event Emitter Api "once"
0 commit comments