From 58e4980bc36575b69cb5c0194ce59df3611cf179 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 13 Jul 2022 00:19:23 +0300 Subject: [PATCH] update mongo aggregate caller --- src/structure/storage/interfaces/MongodbTable.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/structure/storage/interfaces/MongodbTable.js b/src/structure/storage/interfaces/MongodbTable.js index af5c6d6..1f5f247 100644 --- a/src/structure/storage/interfaces/MongodbTable.js +++ b/src/structure/storage/interfaces/MongodbTable.js @@ -38,13 +38,8 @@ class MongodbTable { aggregate(query) { query = this._handleData(query); - return new Promise((resolve, reject) => { - if (!this.provider._initialized) return reject(new Error('MongoDB is not connected.')); - this.collection.aggregate(query, (error, item) => { - if (error) return reject(error); - return resolve(item.toArray()); - }); - }); + if (!this.provider._initialized) return Promise.reject(new Error('MongoDB is not connected.')); + return this.collection.aggregate(query).toArray(); } random(query, amount = 1) {