mirror of
https://github.com/docmost/docmost.git
synced 2026-07-26 12:44:44 +10:00
refactor(base): rename baseId to pageId in BaseViewRepo
This commit is contained in:
@@ -30,42 +30,42 @@ export class BaseViewRepo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findByBaseId(
|
async findByBaseId(
|
||||||
baseId: string,
|
pageId: string,
|
||||||
opts: WorkspaceOpts,
|
opts: WorkspaceOpts,
|
||||||
): Promise<BaseView[]> {
|
): Promise<BaseView[]> {
|
||||||
const db = dbOrTx(this.db, opts.trx);
|
const db = dbOrTx(this.db, opts.trx);
|
||||||
return db
|
return db
|
||||||
.selectFrom('baseViews')
|
.selectFrom('baseViews')
|
||||||
.selectAll()
|
.selectAll()
|
||||||
.where('baseId', '=', baseId)
|
.where('pageId', '=', pageId)
|
||||||
.where('workspaceId', '=', opts.workspaceId)
|
.where('workspaceId', '=', opts.workspaceId)
|
||||||
.orderBy('position', 'asc')
|
.orderBy('position', 'asc')
|
||||||
.execute() as Promise<BaseView[]>;
|
.execute() as Promise<BaseView[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
async countByBaseId(
|
async countByBaseId(
|
||||||
baseId: string,
|
pageId: string,
|
||||||
opts: WorkspaceOpts,
|
opts: WorkspaceOpts,
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const db = dbOrTx(this.db, opts.trx);
|
const db = dbOrTx(this.db, opts.trx);
|
||||||
const result = await db
|
const result = await db
|
||||||
.selectFrom('baseViews')
|
.selectFrom('baseViews')
|
||||||
.select((eb) => eb.fn.countAll<number>().as('count'))
|
.select((eb) => eb.fn.countAll<number>().as('count'))
|
||||||
.where('baseId', '=', baseId)
|
.where('pageId', '=', pageId)
|
||||||
.where('workspaceId', '=', opts.workspaceId)
|
.where('workspaceId', '=', opts.workspaceId)
|
||||||
.executeTakeFirstOrThrow();
|
.executeTakeFirstOrThrow();
|
||||||
return Number(result.count);
|
return Number(result.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLastPosition(
|
async getLastPosition(
|
||||||
baseId: string,
|
pageId: string,
|
||||||
opts: WorkspaceOpts,
|
opts: WorkspaceOpts,
|
||||||
): Promise<string | null> {
|
): Promise<string | null> {
|
||||||
const db = dbOrTx(this.db, opts.trx);
|
const db = dbOrTx(this.db, opts.trx);
|
||||||
const result = await db
|
const result = await db
|
||||||
.selectFrom('baseViews')
|
.selectFrom('baseViews')
|
||||||
.select('position')
|
.select('position')
|
||||||
.where('baseId', '=', baseId)
|
.where('pageId', '=', pageId)
|
||||||
.where('workspaceId', '=', opts.workspaceId)
|
.where('workspaceId', '=', opts.workspaceId)
|
||||||
.orderBy(sql`position COLLATE "C"`, 'desc')
|
.orderBy(sql`position COLLATE "C"`, 'desc')
|
||||||
.limit(1)
|
.limit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user