Skip to content

Commit 3717676

Browse files
committed
default value when fetch is blank
1 parent 32abde1 commit 3717676

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inspatial/cloud",
3-
"version": "0.7.27",
3+
"version": "0.7.28",
44
"license": "Apache-2.0",
55
"exports": {
66
".": "./mod.ts",

src/orm/shared/base-class.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,15 @@ export class BaseClass<N extends string = string> {
189189
const def = this._getFieldDef<"ConnectionField">(
190190
field.fetchField.connectionField,
191191
);
192-
const value = await this._db.getValue(
193-
`entry_${def.entryType}`,
194-
this._data.get(def.key),
195-
field.fetchField.fetchField,
196-
);
192+
const id = this._data.get(def.key);
193+
let value = field.defaultValue;
194+
if (id) {
195+
value = await this._db.getValue(
196+
`entry_${def.entryType}`,
197+
id,
198+
field.fetchField.fetchField,
199+
);
200+
}
197201
this[`$${field.key}` as keyof typeof this] = value;
198202
}
199203
}

0 commit comments

Comments
 (0)