More gohst user

This commit is contained in:
Daniel Hougaard
2024-02-22 05:00:14 +01:00
parent 84cab17f5c
commit 3b1fc4b156
15 changed files with 413 additions and 275 deletions
@@ -52,6 +52,20 @@ export const projectDALFactory = (db: TDbClient) => {
}
};
const findProjectGhostUser = async (projectId: string) => {
try {
const ghostUser = await db(TableName.ProjectMembership)
.where({ projectId })
.join(TableName.Users, `${TableName.ProjectMembership}.userId`, `${TableName.Users}.id`)
.select(selectAllTableCols(TableName.Users))
.where({ ghost: true })
.first();
return ghostUser;
} catch (error) {
throw new DatabaseError({ error, name: "Find project ghost user" });
}
};
const findAllProjectsByIdentity = async (identityId: string) => {
try {
const workspaces = await db(TableName.IdentityProjectMembership)
@@ -136,6 +150,7 @@ export const projectDALFactory = (db: TDbClient) => {
...projectOrm,
findAllProjects,
findAllProjectsByIdentity,
findProjectGhostUser,
findProjectById
};
};