Skip to content

Commit 864ac4e

Browse files
committed
fix: implementation error in mongoDB client implementation
1 parent 94d807d commit 864ac4e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/db/mongo/repo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ export const getRepos = async (query: any = {}): Promise<Repo[]> => {
1616
export const getRepo = async (name: string): Promise<Repo | null> => {
1717
name = name.toLowerCase();
1818
const collection = await connect(collectionName);
19-
const doc = collection.findOne({ name: { $eq: name } });
19+
const doc = await collection.findOne({ name: { $eq: name } });
2020
return doc ? toClass(doc, Repo.prototype) : null;
2121
};
2222

2323
export const getRepoByUrl = async (repoUrl: string): Promise<Repo | null> => {
2424
const collection = await connect(collectionName);
25-
const doc = collection.findOne({ name: { $eq: repoUrl.toLowerCase() } });
25+
const doc = await collection.findOne({ url: { $eq: repoUrl.toLowerCase() } });
2626
return doc ? toClass(doc, Repo.prototype) : null;
2727
};
2828

2929
export const getRepoById = async (_id: string): Promise<Repo | null> => {
3030
const collection = await connect(collectionName);
31-
const doc = collection.findOne({ _id: new ObjectId(_id) });
31+
const doc = await collection.findOne({ _id: new ObjectId(_id) });
3232
return doc ? toClass(doc, Repo.prototype) : null;
3333
};
3434

src/db/mongo/users.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ const collectionName = 'users';
77

88
export const findUser = async function (username: string): Promise<User | null> {
99
const collection = await connect(collectionName);
10-
const doc = collection.findOne({ username: { $eq: username.toLowerCase() } });
10+
const doc = await collection.findOne({ username: { $eq: username.toLowerCase() } });
1111
return doc ? toClass(doc, User.prototype) : null;
1212
};
1313

1414
export const findUserByEmail = async function (email: string): Promise<User | null> {
1515
const collection = await connect(collectionName);
16-
const doc = collection.findOne({ email: { $eq: email.toLowerCase() } });
16+
const doc = await collection.findOne({ email: { $eq: email.toLowerCase() } });
1717
return doc ? toClass(doc, User.prototype) : null;
1818
};
1919

2020
export const findUserByOIDC = async function (oidcId: string): Promise<User | null> {
2121
const collection = await connect(collectionName);
22-
const doc = collection.findOne({ oidcId: { $eq: oidcId } });
22+
const doc = await collection.findOne({ oidcId: { $eq: oidcId } });
2323
return doc ? toClass(doc, User.prototype) : null;
2424
};
2525

0 commit comments

Comments
 (0)