You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -788,10 +795,29 @@ export class CollectionInstance<
788
795
this._internalStore._data.delete(key)
789
796
}
790
797
// if an array, iterate through the keys and remove them each
791
-
if(Array.isArray(keys)){
792
-
keys.forEach(rm)
793
-
}else{
794
-
rm(keys)
798
+
keys=Array.isArray(keys) ? keys : [keys]
799
+
800
+
// if the instance is batching and this collection has batching enabled, add this action to the batchedSetters
801
+
if(
802
+
// this.instance().runtime.isBatching &&
803
+
this.config.useBatching
804
+
){
805
+
this.instance().runtime.log(
806
+
'debug',
807
+
`Batching an delete call for collection ${this.instanceId}`
808
+
)
809
+
this.instance().runtime.startBatching()
810
+
}
811
+
// run this remove call
812
+
for(constkeyofkeys){
813
+
rm(key)
814
+
}
815
+
if(this.config.useBatching){
816
+
this.instance().runtime.endBatching()
817
+
this.instance().runtime.log(
818
+
'debug',
819
+
`Batched delete call fulfilled for collection ${this.instanceId}`
820
+
)
795
821
}
796
822
this.mount()
797
823
returnthis
@@ -836,10 +862,9 @@ export class CollectionInstance<
836
862
}
837
863
838
864
// if an array, iterate through the keys and remove them from each associated group
839
-
if(Array.isArray(keys)){
840
-
keys.forEach(rm)
841
-
}else{
842
-
rm(keys)
865
+
keys=Array.isArray(keys) ? keys : [keys]
866
+
for(letkeyofkeys){
867
+
rm(key)
843
868
}
844
869
returnthis
845
870
// ! This is commented out because the user may still want to keep the data in the collection. If they want to completely delete the data, they should use `.delete()`
@@ -856,13 +881,9 @@ export class CollectionInstance<
856
881
clear(groupNames?: KeyOfMap<Groups>|KeyOfMap<Groups>[]): this {
857
882
// this means we want to clear a group, not the whole collection
0 commit comments