From 83bf05e5a246b5facbed52bc69827e212ff04921 Mon Sep 17 00:00:00 2001 From: Navy Date: Thu, 23 Jul 2020 23:41:52 +0300 Subject: [PATCH] some stuff --- storage/providers/Mongodb.js | 5 ++++- structure/client/Resolver.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/providers/Mongodb.js b/storage/providers/Mongodb.js index 70c3f7e..28c162c 100644 --- a/storage/providers/Mongodb.js +++ b/storage/providers/Mongodb.js @@ -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); diff --git a/structure/client/Resolver.js b/structure/client/Resolver.js index fcbdb09..60b424c 100644 --- a/structure/client/Resolver.js +++ b/structure/client/Resolver.js @@ -419,7 +419,7 @@ class Resolver { if(channel) resolved.push(channel); - } + } }