mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-04 13:01:10 +08:00
added a is name available check
This commit is contained in:
parent
35de40dda1
commit
ecef2da2eb
1 changed files with 11 additions and 0 deletions
|
@ -20,6 +20,17 @@ class UsersDAO {
|
|||
.updateOne({ uid }, { $set: { name } });
|
||||
}
|
||||
|
||||
static async isNameAvailable(name) {
|
||||
const nameDoc = await mongoDB()
|
||||
.collection("users")
|
||||
.findOne({ name });
|
||||
if (nameDoc){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static async updateEmail(uid, email) {
|
||||
const user = await mongoDB().collection("users").findOne({ uid });
|
||||
if (!user) throw new MonkeyError(404, "User not found");
|
||||
|
|
Loading…
Reference in a new issue