From c5d2b292aae3322eadc2b622acdf395fe7619dac Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 22 Apr 2022 18:11:52 +0300 Subject: [PATCH] update mongo find code to match new version --- src/structure/storage/interfaces/MongodbTable.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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: ... }