forked from xolvio/cleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcleaner.js
27 lines (24 loc) · 908 Bytes
/
cleaner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
resetDatabase = function (options) {
if (Meteor.settings.backdoor !== true) {
throw new Error(
'resetDatabase is not allowed outside of a development mode. ' +
'Aborting.'
);
}
options = options || {};
var excludedCollections = ['system.indexes'];
if (options.excludedCollections) {
excludedCollections = excludedCollections.concat(options.excludedCollections);
}
var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
var getCollections = Meteor.wrapAsync(db.collections, db);
var collections = getCollections();
var appCollections = _.reject(collections, function (col) {
return col.collectionName.indexOf('velocity') === 0 ||
excludedCollections.indexOf(col.collectionName) !== -1;
});
_.each(appCollections, function (appCollection) {
var remove = Meteor.wrapAsync(appCollection.remove, appCollection);
remove({});
});
};