diff --git a/package.json b/package.json index 8544787d40..ff2a62a3dd 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "lint-fix": "eslint --fix --cache ./", "build": "babel src/ -d lib/ --copy-files", "watch": "babel --watch src/ -d lib/ --copy-files", - "test:mongodb:runnerstart": "cross-env mongodb-runner start -t standalone --version $npm_config_dbversion -- --port 27017", + "test:mongodb:runnerstart": "cross-env mongodb-runner stop --all && mongodb-runner start -t standalone --version $npm_config_dbversion -- --port 27017", "test:mongodb:testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=$npm_config_dbversion} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} TESTING=1 jasmine", "test:mongodb": "npm run test:mongodb:runnerstart --dbversion=$npm_config_dbversion && npm run test:mongodb:testonly --dbversion=$npm_config_dbversion", "test:mongodb:4.2.19": "npm run test:mongodb --dbversion=4.2.19", diff --git a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js index cdaccbb709..268a9ed1aa 100644 --- a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js +++ b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js @@ -31,6 +31,8 @@ const storageAdapterAllCollections = mongoAdapter => { .connect() .then(() => mongoAdapter.database.collections()) .then(collections => { + if (!collections || !collections.length) return []; + return collections.filter(collection => { if (collection.namespace.match(/\.system\./)) { return false; @@ -399,6 +401,7 @@ export class MongoStorageAdapter implements StorageAdapter { } deleteAllClasses(fast: boolean) { + // @flow-disable-next return storageAdapterAllCollections(this).then(collections => Promise.all( collections.map(collection => (fast ? collection.deleteMany({}) : collection.drop()))