@zuzjs/orm 0.2.8 → 0.3.0
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.
|
@@ -20,6 +20,7 @@ declare class ZormQueryBuilder<T extends ObjectLiteral, R = QueryResult> extends
|
|
|
20
20
|
_getRawQuery(): [string, any[]];
|
|
21
21
|
active(): this;
|
|
22
22
|
_saveActiveRecord(activeRecord: T): Promise<T | null>;
|
|
23
|
+
clone(): ZormQueryBuilder<T, R>;
|
|
23
24
|
/**
|
|
24
25
|
* Sets the values for an insert or update query.
|
|
25
26
|
* @param data - The data to be inserted or updated.
|
|
@@ -96,6 +96,16 @@ class ZormQueryBuilder extends Promise {
|
|
|
96
96
|
return this.repository.save(activeRecord);
|
|
97
97
|
// return this
|
|
98
98
|
}
|
|
99
|
+
clone() {
|
|
100
|
+
const cloned = new ZormQueryBuilder(this.repository, this.action, this.usePromise);
|
|
101
|
+
cloned.queryBuilder = this.queryBuilder.clone(); // Deep clone of query builder
|
|
102
|
+
cloned.entityAlias = this.entityAlias;
|
|
103
|
+
cloned.queryValues = this.queryValues ? structuredClone(this.queryValues) : null;
|
|
104
|
+
cloned.whereCount = this.whereCount;
|
|
105
|
+
cloned.isActiveRecord = this.isActiveRecord;
|
|
106
|
+
cloned.activeRecord = this.activeRecord;
|
|
107
|
+
return cloned;
|
|
108
|
+
}
|
|
99
109
|
/**
|
|
100
110
|
* Sets the values for an insert or update query.
|
|
101
111
|
* @param data - The data to be inserted or updated.
|
|
@@ -417,7 +427,7 @@ class ZormQueryBuilder extends Promise {
|
|
|
417
427
|
hasRows: _select.length > 0,
|
|
418
428
|
count: _select.length,
|
|
419
429
|
row: _select.length > 0 ? _select[0] : null,
|
|
420
|
-
rows: _select.length
|
|
430
|
+
rows: _select.length == 1 ? [_select[0]] : _select,
|
|
421
431
|
};
|
|
422
432
|
if (this.isActiveRecord) {
|
|
423
433
|
_result.save = () => this._saveActiveRecord(_select[0]);
|