update mongo aggregate caller

This commit is contained in:
Erik 2022-07-13 00:19:23 +03:00
parent 67e796d334
commit 58e4980bc3
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

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