forked from Galactic/galactic-bot
options for sorting, skipping and limit in mongo
This commit is contained in:
parent
4ab77f9b71
commit
09f262ab8c
@ -13,11 +13,15 @@ class MongodbTable {
|
||||
|
||||
//Data Search
|
||||
|
||||
async find(query, opts = {}) { //opts: { projection: ... }
|
||||
async find(query, opts = {}, { sort, skip, limit } = {}) { //opts: { projection: ... }
|
||||
query = this._handleData(query);
|
||||
if (!this.provider._initialized) return Promise.reject(new Error('MongoDB is not connected.'));
|
||||
|
||||
const cursor = await this.collection.find(query, opts);
|
||||
if (sort) cursor.sort(sort);
|
||||
if (skip) cursor.skip(skip);
|
||||
if (limit) cursor.limit(limit);
|
||||
|
||||
return cursor.toArray();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user