cleanup of mongo wrapper
This commit is contained in:
parent
7da9adf8a5
commit
426b22489b
@ -84,20 +84,9 @@ class MongoDB {
|
||||
* @returns {Object} An object containing the queried data
|
||||
* @memberof Database
|
||||
*/
|
||||
async findOne (db, query, options) {
|
||||
async findOne (db, query, options = {}) {
|
||||
|
||||
this.logger.debug(`Incoming findOne query for ${db} with parameters ${JSON.stringify(query)}`);
|
||||
// return new Promise((resolve, reject) => {
|
||||
|
||||
// this.db.collection(db).findOne(query, async (error, item) => {
|
||||
|
||||
// if (error) return reject(error);
|
||||
// return resolve(item);
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
const result = await this.db.collection(db).findOne(query, options);
|
||||
return result;
|
||||
|
||||
@ -116,16 +105,6 @@ class MongoDB {
|
||||
|
||||
this.logger.debug(`Incoming update query for '${db}' with parameters\n${JSON.stringify(filter)}\nand data\n${JSON.stringify(data)}`);
|
||||
if (!filter) throw new Error(`Cannot run update many without a filter, if you mean to update every single document, pass an empty object`);
|
||||
// this.logger.warn('Database.update() is deprecated!');
|
||||
// return new Promise((resolve, reject) => {
|
||||
|
||||
// this.db.collection(db).updateMany(filter, data, async (error, result) => {
|
||||
// if (error) return reject(error);
|
||||
// return resolve(result);
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
const result = await this.db.collection(db).updateMany(filter, { $set: data }, { upsert });
|
||||
return result;
|
||||
|
||||
@ -143,20 +122,6 @@ class MongoDB {
|
||||
async updateOne (db, filter, data, upsert = false) {
|
||||
|
||||
this.logger.debug(`Incoming updateOne query for ${db} with parameters ${JSON.stringify(filter)}`);
|
||||
// return new Promise((resolve, reject) => {
|
||||
|
||||
// this.db.collection(db).updateOne(filter, { $set: data }, { upsert }, async (error, result) => {
|
||||
|
||||
// if (error) return reject(error);
|
||||
|
||||
// // return resolve(result)
|
||||
// const { matchedCount, upsertedCount, modifiedCount } = result;
|
||||
// return resolve({ matched: matchedCount, upserted: upsertedCount, modified: modifiedCount });
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
const result = await this.db.collection(db).updateOne(filter, { $set: data }, { upsert });
|
||||
return result;
|
||||
|
||||
@ -175,17 +140,6 @@ class MongoDB {
|
||||
async push (db, filter, data, upsert = false) {
|
||||
|
||||
this.logger.debug(`Incoming push query for ${db}, with upsert ${upsert} and with parameters ${JSON.stringify(filter)} and data ${JSON.stringify(data)}`);
|
||||
// return new Promise((resolve, reject) => {
|
||||
|
||||
// this.db.collection(db).updateOne(filter, { $push: data }, { upsert }, async (error, result) => {
|
||||
|
||||
// if (error) return reject(error);
|
||||
// return resolve(result);
|
||||
|
||||
// });
|
||||
|
||||
// });
|
||||
|
||||
const result = await this.db.collection(db).updateOne(filter, { $push: data }, { upsert });
|
||||
return result;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user