Skip to content

Commit 558c237

Browse files
committed
Remove _allCollections as Parse Server doesn't need it.
1 parent 1786bb4 commit 558c237

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ let MongoClient = mongodb.MongoClient;
1010
const MongoSchemaCollectionName = '_SCHEMA';
1111
const DefaultMongoURI = 'mongodb://localhost:27017/parse';
1212

13+
const storageAdapterAllCollections = mongoAdapter => {
14+
return mongoAdapter.connect()
15+
.then(() => mongoAdapter.database.collections())
16+
.then(collections => {
17+
return collections.filter(collection => {
18+
if (collection.namespace.match(/\.system\./)) {
19+
return false;
20+
}
21+
// TODO: If you have one app with a collection prefix that happens to be a prefix of another
22+
// apps prefix, this will go very very badly. We should fix that somehow.
23+
return (collection.collectionName.indexOf(mongoAdapter._collectionPrefix) == 0);
24+
});
25+
});
26+
}
27+
1328
export class MongoStorageAdapter {
1429
// Private
1530
_uri: string;
@@ -86,25 +101,8 @@ export class MongoStorageAdapter {
86101

87102
// Delete all data known to this adatper. Used for testing.
88103
deleteAllSchemas() {
89-
return this._allCollections().then(collections => {
90-
let promises = collections.map(collection => collection.drop());
91-
return Promise.all(promises);
92-
});
93-
}
94-
95-
_allCollections() {
96-
return this.connect()
97-
.then(() => this.database.collections())
98-
.then(collections => {
99-
return collections.filter(collection => {
100-
if (collection.namespace.match(/\.system\./)) {
101-
return false;
102-
}
103-
//TODO: If you have one app with a collection prefix that happens to be a prefix of another
104-
// apps prefix, this will go very very badly. We should fix that somehow.
105-
return (collection.collectionName.indexOf(this._collectionPrefix) == 0);
106-
});
107-
});
104+
return storageAdapterAllCollections(this)
105+
.then(collections => Promise.all(collections.map(collection => collection.drop())));
108106
}
109107

110108
// Remove the column and all the data. For Relations, the _Join collection is handled

0 commit comments

Comments
 (0)