some stuff

This commit is contained in:
Erik 2020-07-23 23:41:52 +03:00
parent 5d374647d8
commit 83bf05e5a2
2 changed files with 5 additions and 2 deletions

View File

@ -43,6 +43,10 @@ class MongoDBProvider extends Provider {
if (!this._initialized) return { error: true, message: 'MongoDB not connected' };
if (!this[request.type]) return { error: true, message: `Invalid request type, got '${request.type}'` };
if (!request.collection && request.type !== 'stats') return { error: true, message: 'You must specify a collection to query!' };
if (request.query?._id) {
if (typeof request.query?._id === 'string') request.query._id = ObjectId(request.query._id);
else if (request.query?._id instanceof Array) request.query._id = { $in: request.query._id.map(id => ObjectId(id)) };
}
return this[request.type](request);
@ -220,7 +224,6 @@ class MongoDBProvider extends Provider {
if(!this._initialized) reject(new Error('MongoDB not connected'));
if(query._id) query._id = ObjectId(query._id); //bullshit
this.db.collection(collection).updateOne(query, { $set: data }, { upsert }, async (error, result) => {
if(error) return reject(error);