@naturalcycles/db-lib 8.28.0 → 8.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,8 +16,8 @@ export declare class CommonDao<BM extends Partial<ObjectWithId>, DBM extends Obj
16
16
  create(part: Partial<BM>, opt?: CommonDaoOptions): Saved<BM>;
17
17
  getById(id: undefined, opt?: CommonDaoOptions): Promise<null>;
18
18
  getById(id?: string, opt?: CommonDaoOptions): Promise<Saved<BM> | null>;
19
- getByIdOrEmpty(id: string, part: Partial<BM>, opt?: CommonDaoOptions): Promise<Saved<BM>>;
20
- getByIdAsDBMOrEmpty(id: string, part: Partial<BM>, opt?: CommonDaoOptions): Promise<DBM>;
19
+ getByIdOrEmpty(id: string, part?: Partial<BM>, opt?: CommonDaoOptions): Promise<Saved<BM>>;
20
+ getByIdAsDBMOrEmpty(id: string, part?: Partial<BM>, opt?: CommonDaoOptions): Promise<DBM>;
21
21
  getByIdAsDBM(id: undefined, opt?: CommonDaoOptions): Promise<null>;
22
22
  getByIdAsDBM(id?: string, opt?: CommonDaoOptions): Promise<DBM | null>;
23
23
  getByIdAsTM(id: undefined, opt?: CommonDaoOptions): Promise<null>;
@@ -71,13 +71,13 @@ class CommonDao {
71
71
  this.logResult(started, op, bm, table);
72
72
  return bm || null;
73
73
  }
74
- async getByIdOrEmpty(id, part, opt) {
74
+ async getByIdOrEmpty(id, part = {}, opt) {
75
75
  const bm = await this.getById(id, opt);
76
76
  if (bm)
77
77
  return bm;
78
78
  return this.create({ ...part, id }, opt);
79
79
  }
80
- async getByIdAsDBMOrEmpty(id, part, opt) {
80
+ async getByIdAsDBMOrEmpty(id, part = {}, opt) {
81
81
  const dbm = await this.getByIdAsDBM(id, opt);
82
82
  if (dbm)
83
83
  return dbm;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "engines": {
44
44
  "node": ">=14.15"
45
45
  },
46
- "version": "8.28.0",
46
+ "version": "8.28.1",
47
47
  "description": "Lowest Common Denominator API to supported Databases",
48
48
  "keywords": [
49
49
  "db",
@@ -124,14 +124,22 @@ export class CommonDao<
124
124
  return bm || null
125
125
  }
126
126
 
127
- async getByIdOrEmpty(id: string, part: Partial<BM>, opt?: CommonDaoOptions): Promise<Saved<BM>> {
127
+ async getByIdOrEmpty(
128
+ id: string,
129
+ part: Partial<BM> = {},
130
+ opt?: CommonDaoOptions,
131
+ ): Promise<Saved<BM>> {
128
132
  const bm = await this.getById(id, opt)
129
133
  if (bm) return bm
130
134
 
131
135
  return this.create({ ...part, id }, opt)
132
136
  }
133
137
 
134
- async getByIdAsDBMOrEmpty(id: string, part: Partial<BM>, opt?: CommonDaoOptions): Promise<DBM> {
138
+ async getByIdAsDBMOrEmpty(
139
+ id: string,
140
+ part: Partial<BM> = {},
141
+ opt?: CommonDaoOptions,
142
+ ): Promise<DBM> {
135
143
  const dbm = await this.getByIdAsDBM(id, opt)
136
144
  if (dbm) return dbm
137
145