Add MongoCollection and adaptiveCollection abstraction to MongoAdapter.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
|
||||
import MongoCollection from './MongoCollection';
|
||||
|
||||
let mongodb = require('mongodb');
|
||||
let MongoClient = mongodb.MongoClient;
|
||||
|
||||
@@ -30,6 +32,12 @@ export class MongoStorageAdapter {
|
||||
});
|
||||
}
|
||||
|
||||
adaptiveCollection(name: string) {
|
||||
return this.connect()
|
||||
.then(() => this.database.collection(name))
|
||||
.then(rawCollection => new MongoCollection(rawCollection));
|
||||
}
|
||||
|
||||
collectionExists(name: string) {
|
||||
return this.connect().then(() => {
|
||||
return this.database.listCollections({ name: name }).toArray();
|
||||
|
||||
Reference in New Issue
Block a user