forked from Galactic/galactic-bot
some stuff
This commit is contained in:
parent
5d374647d8
commit
83bf05e5a2
@ -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);
|
||||
|
@ -419,7 +419,7 @@ class Resolver {
|
||||
|
||||
if(channel) resolved.push(channel);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user