space slug

This commit is contained in:
Philipinho
2024-03-29 17:44:25 +00:00
parent b241523ff6
commit 4ce7676a77
2 changed files with 32 additions and 16 deletions

View File

@ -32,16 +32,25 @@ export class SpaceRepo {
.executeTakeFirst();
}
async slugExists(slug: string, workspaceId: string): Promise<boolean> {
let { count } = await this.db
.selectFrom('spaces')
.select((eb) => eb.fn.count('id').as('count'))
.where(sql`LOWER(slug)`, '=', sql`LOWER(${slug})`)
.where('workspaceId', '=', workspaceId)
.executeTakeFirst();
count = count as number;
return !!count;
async slugExists(
slug: string,
workspaceId: string,
trx?: KyselyTransaction,
): Promise<boolean> {
return executeTx(
this.db,
async (trx) => {
let { count } = await trx
.selectFrom('spaces')
.select((eb) => eb.fn.count('id').as('count'))
.where(sql`LOWER(slug)`, '=', sql`LOWER(${slug})`)
.where('workspaceId', '=', workspaceId)
.executeTakeFirst();
count = count as number;
return count == 0 ? false : true;
},
trx,
);
}
async updateSpace(