Add new MongoSchemaCollection class that manages schemas for all collections.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
|
||||
import MongoCollection from './MongoCollection';
|
||||
import MongoSchemaCollection from './MongoSchemaCollection';
|
||||
|
||||
let mongodb = require('mongodb');
|
||||
let MongoClient = mongodb.MongoClient;
|
||||
|
||||
const MongoSchemaCollectionName = '_SCHEMA';
|
||||
|
||||
export class MongoStorageAdapter {
|
||||
// Private
|
||||
_uri: string;
|
||||
@@ -38,6 +41,12 @@ export class MongoStorageAdapter {
|
||||
.then(rawCollection => new MongoCollection(rawCollection));
|
||||
}
|
||||
|
||||
schemaCollection(collectionPrefix: string) {
|
||||
return this.connect()
|
||||
.then(() => this.adaptiveCollection(collectionPrefix + MongoSchemaCollectionName))
|
||||
.then(collection => new MongoSchemaCollection(collection));
|
||||
}
|
||||
|
||||
collectionExists(name: string) {
|
||||
return this.connect().then(() => {
|
||||
return this.database.listCollections({ name: name }).toArray();
|
||||
|
||||
Reference in New Issue
Block a user