Skip to content

Commit 4f9ebf2

Browse files
committed
Use deleteObjectsByQuery
1 parent a540036 commit 4f9ebf2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ export class MongoStorageAdapter {
9595
});
9696
}
9797

98-
purgeCollection(name: string) {
99-
return this.collection(this._collectionPrefix + name).then(collection => collection.remove({}));
100-
}
101-
10298
// Deletes a schema. Resolve if successful. If the schema doesn't
10399
// exist, resolve with undefined. If schema exists, but can't be deleted for some other reason,
104100
// reject with INTERNAL_SERVER_ERROR.

src/Controllers/DatabaseController.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ DatabaseController.prototype.collectionExists = function(className) {
7676
};
7777

7878
DatabaseController.prototype.purgeCollection = function(className) {
79-
return this.adapter.purgeCollection(className);
79+
return this.loadSchema()
80+
.then((schema) => {
81+
schema.getOneSchema(className)
82+
})
83+
.then((schema) => {
84+
this.adapter.deleteObjectsByQuery(className, {}, schema);
85+
});
8086
};
8187

8288
DatabaseController.prototype.validateClassName = function(className) {

0 commit comments

Comments
 (0)