diff --git a/src/commondao/common.dao.ts b/src/commondao/common.dao.ts index 399d240..564e8b1 100644 --- a/src/commondao/common.dao.ts +++ b/src/commondao/common.dao.ts @@ -1432,9 +1432,10 @@ export class CommonDaoTransaction { async getById, DBM extends ObjectWithId>( dao: CommonDao, - id: string, + id?: string | null, opt?: CommonDaoOptions, ): Promise | null> { + if (!id) return null return (await this.getByIds(dao, [id], opt))[0] || null } @@ -1476,7 +1477,12 @@ export class CommonDaoTransaction { return await dao.saveBatch(bms, { ...opt, tx: this.tx }) } - async deleteById(dao: CommonDao, id: string, opt?: CommonDaoOptions): Promise { + async deleteById( + dao: CommonDao, + id?: string | null, + opt?: CommonDaoOptions, + ): Promise { + if (!id) return 0 return await this.deleteByIds(dao, [id], opt) }