Skip to content

Commit

Permalink
fix(database): use collections instead listCollections
Browse files Browse the repository at this point in the history
  • Loading branch information
Duy Luong committed Dec 24, 2017
1 parent 8446f39 commit dfed4a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class Database {
createCollection: async (collectionName, callback) => {
// debug('create collection', {collectionName})
const db = await this.connect()
const collections = await db.listCollections().toArray()
const collections = await db.collections()
if (_.find(collections, collection => collection.name === collectionName)) {
throw new Error('already exists')
}
Expand All @@ -187,7 +187,7 @@ class Database {
createCollectionIfNotExists: async (collectionName, callback) => {
// debug('create collection if not exists', { collectionName })
const db = await this.connect()
const collections = await db.listCollections().toArray()
const collections = await db.collections()
if (!_.find(collections, collection => collection.name === collectionName)) {
const collection = await db.createCollection(collectionName)
const schemaBuilder = new SchemaBuilder(collection)
Expand All @@ -203,7 +203,7 @@ class Database {
dropCollectionIfExists: async (collectionName) => {
// debug('drop collection if not exists', { collectionName })
const db = await this.connect()
const collections = await db.listCollections().toArray()
const collections = await db.collections()
if (_.find(collections, collection => collection.name === collectionName)) {
return db.dropCollection(collectionName)
}
Expand All @@ -215,7 +215,7 @@ class Database {
},
hasCollection: async (collectionName) => {
const db = await this.connect()
const collections = await db.listCollections().toArray()
const collections = await db.collections()
return !!_.find(collections, collection => collection.name === collectionName)
}
}
Expand Down

0 comments on commit dfed4a0

Please sign in to comment.