forked from Galactic/galactic-bot
update mongo find code to match new version
This commit is contained in:
parent
61b2106db5
commit
c5d2b292aa
@ -13,15 +13,12 @@ class MongodbTable {
|
|||||||
|
|
||||||
//Data Search
|
//Data Search
|
||||||
|
|
||||||
find(query, opts = {}) { //opts: { projection: ... }
|
async find(query, opts = {}) { //opts: { projection: ... }
|
||||||
query = this._handleData(query);
|
query = this._handleData(query);
|
||||||
return new Promise((resolve, reject) => {
|
if (!this.provider._initialized) return Promise.reject(new Error('MongoDB is not connected.'));
|
||||||
if (!this.provider._initialized) return reject(new Error('MongoDB is not connected.'));
|
|
||||||
this.collection.find(query, opts, async (error, cursor) => {
|
const cursor = await this.collection.find(query, opts);
|
||||||
if (error) return reject(error);
|
return cursor.toArray();
|
||||||
return resolve(await cursor.toArray());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
findOne(query, opts = {}) { //opts: { projection: ..., sort: ... }
|
findOne(query, opts = {}) { //opts: { projection: ..., sort: ... }
|
||||||
|
Loading…
Reference in New Issue
Block a user