update mongo find code to match new version

This commit is contained in:
Erik 2022-04-22 18:11:52 +03:00
parent 61b2106db5
commit c5d2b292aa
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB

View File

@ -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: ... }