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) {