diff --git a/src/structure/storage/interfaces/MongodbTable.js b/src/structure/storage/interfaces/MongodbTable.js index bdedd06..a2c0768 100644 --- a/src/structure/storage/interfaces/MongodbTable.js +++ b/src/structure/storage/interfaces/MongodbTable.js @@ -13,15 +13,12 @@ class MongodbTable { //Data Search - find(query, opts = {}) { //opts: { projection: ... } + async find(query, opts = {}) { //opts: { projection: ... } query = this._handleData(query); - return new Promise((resolve, reject) => { - if (!this.provider._initialized) return reject(new Error('MongoDB is not connected.')); - this.collection.find(query, opts, async (error, cursor) => { - if (error) return reject(error); - return resolve(await cursor.toArray()); - }); - }); + if (!this.provider._initialized) return Promise.reject(new Error('MongoDB is not connected.')); + + const cursor = await this.collection.find(query, opts); + return cursor.toArray(); } findOne(query, opts = {}) { //opts: { projection: ..., sort: ... }