new keyworkd for objectid
This commit is contained in:
parent
3b63f02dd7
commit
4f12444a9d
@ -64,7 +64,7 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
if (id.includes('temp'))
|
||||
return null;
|
||||
|
||||
const data = await this.db.findOne(this._userColllection, { _id: ObjectId(id) });
|
||||
const data = await this.db.findOne(this._userColllection, { _id: new ObjectId(id) });
|
||||
if (!data)
|
||||
return null;
|
||||
|
||||
@ -85,7 +85,7 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
if (!force && this.cache.has(id))
|
||||
return this.cache.get(id);
|
||||
|
||||
const data = await this.db.findOne(this._appCollection, { _id: ObjectId(id) });
|
||||
const data = await this.db.findOne(this._appCollection, { _id: new ObjectId(id) });
|
||||
if (!data)
|
||||
return null;
|
||||
|
||||
@ -238,11 +238,11 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
return false;
|
||||
if (result.created + result.validFor < Date.now()) {
|
||||
// Code existed but is no longer valid
|
||||
await this.db.deleteOne('registrationCodes', { _id: ObjectId(result._id) });
|
||||
await this.db.deleteOne('registrationCodes', { _id: new ObjectId(result._id) });
|
||||
return false;
|
||||
}
|
||||
// Valid code
|
||||
await this.db.deleteOne('registrationCodes', { _id: ObjectId(result._id) });
|
||||
await this.db.deleteOne('registrationCodes', { _id: new ObjectId(result._id) });
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
const { json } = user;
|
||||
this.logger.debug(`Updating user ${inspect(json)}`);
|
||||
if (user._id)
|
||||
await this.db.updateOne(this._userColllection, { _id: ObjectId(user._id) }, json);
|
||||
await this.db.updateOne(this._userColllection, { _id: new ObjectId(user._id) }, json);
|
||||
else {
|
||||
const result = await this.db.insertOne(this._userColllection, json);
|
||||
user._id = result.insertedId;
|
||||
@ -267,7 +267,7 @@ class UserDatabase extends AbstractUserDatabase {
|
||||
async updateApplication (app) {
|
||||
const { json } = app;
|
||||
this.logger.debug(`Updating application ${inspect(json)}`);
|
||||
await this.db.updateOne(this._appCollection, { _id: ObjectId(json._id) }, json, true);
|
||||
await this.db.updateOne(this._appCollection, { _id: new ObjectId(json._id) }, json, true);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user