fixing things across the board

This commit is contained in:
talksik
2022-03-18 10:03:57 -04:00
parent 9613e2b2cf
commit 3488278d2d
10 changed files with 95 additions and 52 deletions
+21 -1
View File
@@ -8,7 +8,27 @@ export class UserService {
static async getUserById(userId: string) {
const query = { _id: new ObjectId(userId) };
return (await collections.users?.findOne(query)) as unknown as User;
const res = await collections.users?.findOne(query);
// exists
if (res?._id) {
return res as User;
}
return null;
}
static async getUserByEmail(email: string) {
const query = { email };
const res = await collections.users?.findOne(query);
// exists
if (res?._id) {
return res as User;
}
return null;
}
static async createUserIfNotExists(newUser: User) {