Skip to content

Commit

Permalink
fix: CommonDaoTransaction allow falsy singular id's
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Jan 17, 2024
1 parent 32ac3ab commit de67d7e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commondao/common.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1432,9 +1432,10 @@ export class CommonDaoTransaction {

async getById<BM extends Partial<ObjectWithId>, DBM extends ObjectWithId>(
dao: CommonDao<BM, DBM, any>,
id: string,
id?: string | null,
opt?: CommonDaoOptions,
): Promise<Saved<BM> | null> {
if (!id) return null
return (await this.getByIds(dao, [id], opt))[0] || null
}

Expand Down Expand Up @@ -1476,7 +1477,12 @@ export class CommonDaoTransaction {
return await dao.saveBatch(bms, { ...opt, tx: this.tx })
}

async deleteById(dao: CommonDao<any>, id: string, opt?: CommonDaoOptions): Promise<number> {
async deleteById(
dao: CommonDao<any>,
id?: string | null,
opt?: CommonDaoOptions,
): Promise<number> {
if (!id) return 0
return await this.deleteByIds(dao, [id], opt)
}

Expand Down

0 comments on commit de67d7e

Please sign in to comment.