From a53187bea417139681be455452427042ffb038a2 Mon Sep 17 00:00:00 2001 From: kirillgroshkov Date: Tue, 4 Jan 2022 18:51:30 +0100 Subject: [PATCH] fix: getByIdOrEmpty --- src/commondao/common.dao.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/commondao/common.dao.ts b/src/commondao/common.dao.ts index 6607720..f2c6867 100644 --- a/src/commondao/common.dao.ts +++ b/src/commondao/common.dao.ts @@ -124,14 +124,22 @@ export class CommonDao< return bm || null } - async getByIdOrEmpty(id: string, part: Partial, opt?: CommonDaoOptions): Promise> { + async getByIdOrEmpty( + id: string, + part: Partial = {}, + opt?: CommonDaoOptions, + ): Promise> { const bm = await this.getById(id, opt) if (bm) return bm return this.create({ ...part, id }, opt) } - async getByIdAsDBMOrEmpty(id: string, part: Partial, opt?: CommonDaoOptions): Promise { + async getByIdAsDBMOrEmpty( + id: string, + part: Partial = {}, + opt?: CommonDaoOptions, + ): Promise { const dbm = await this.getByIdAsDBM(id, opt) if (dbm) return dbm