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); - } + } }