transforming response and getting the right object back for the line

This commit is contained in:
talksik
2022-05-05 08:56:40 -05:00
parent d013212054
commit 7f5eba7732
7 changed files with 116 additions and 38 deletions
+14
View File
@@ -46,6 +46,20 @@ export class LineService {
return null;
}
/** Get all of the members associated to the given list of lines */
static async getLineMembersInLines(lineIds: ObjectId[]) {
const query = { lineId: { $in: lineIds } };
const lineMembersRes = await collections.lineMembers?.find(query).toArray();
// exists
if (lineMembersRes?.length) {
return lineMembersRes as LineMember[];
}
return null;
}
static async createLine(line: Line, lineMembers: LineMember[]) {
const session = client.startSession();
try {
+13
View File
@@ -19,6 +19,19 @@ export class UserService {
return null;
}
static async getUsersByIds(userIds: ObjectId[]) {
const query = { _id: { $in: userIds } };
const res = await collections.users?.find(query).toArray();
// exists
if (res?.length) {
return res as User[];
}
return undefined;
}
static async getUserByGoogleId(googleUserId: string) {
const query = { googleId: googleUserId };