Move and cleanup getting collections into MongoStorageAdapter.

This commit is contained in:
Nikita Lutsenko
2016-02-27 03:02:38 -08:00
parent 7215300c1e
commit eb892830e6
3 changed files with 25 additions and 15 deletions

View File

@@ -23,6 +23,26 @@ export class MongoStorageAdapter {
});
return this.connectionPromise;
}
collection(name: string) {
return this.connect().then(() => {
return this.database.collection(name);
});
}
// Used for testing only right now.
collectionsContaining(match: string) {
return this.connect().then(() => {
return this.database.collections();
}).then(collections => {
return collections.filter(collection => {
if (collection.namespace.match(/\.system\./)) {
return false;
}
return (collection.collectionName.indexOf(match) == 0);
});
});
}
}
export default MongoStorageAdapter;