Feat: Find users by project membership ID's

This commit is contained in:
Daniel Hougaard
2024-05-07 17:30:35 +02:00
parent 8e1d19c041
commit c5d11eee7f
+12
View File
@@ -74,6 +74,17 @@ export const userDALFactory = (db: TDbClient) => {
} }
}; };
const findUsersByProjectMembershipIds = async (projectMembershipIds: string[]) => {
try {
return await db(TableName.ProjectMembership)
.whereIn(`${TableName.ProjectMembership}.id`, projectMembershipIds)
.join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
.select("*");
} catch (error) {
throw new DatabaseError({ error, name: "Find users by project membership ids" });
}
};
const createUserEncryption = async (data: TUserEncryptionKeysInsert, tx?: Knex) => { const createUserEncryption = async (data: TUserEncryptionKeysInsert, tx?: Knex) => {
try { try {
const [userEnc] = await (tx || db)(TableName.UserEncryptionKey).insert(data).returning("*"); const [userEnc] = await (tx || db)(TableName.UserEncryptionKey).insert(data).returning("*");
@@ -140,6 +151,7 @@ export const userDALFactory = (db: TDbClient) => {
findUserEncKeyByUserId, findUserEncKeyByUserId,
updateUserEncryptionByUserId, updateUserEncryptionByUserId,
findUserByProjectMembershipId, findUserByProjectMembershipId,
findUsersByProjectMembershipIds,
upsertUserEncryptionKey, upsertUserEncryptionKey,
createUserEncryption, createUserEncryption,
findOneUserAction, findOneUserAction,