relq 1.0.44 → 1.0.45
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.
|
@@ -30,19 +30,26 @@ class ConnectedCountBuilder {
|
|
|
30
30
|
wrapConditionBuilder(originalBuilder) {
|
|
31
31
|
const relq = this.relq;
|
|
32
32
|
const tableName = this.tableName;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const createProxy = (target) => {
|
|
34
|
+
return new Proxy(target, {
|
|
35
|
+
get(target, prop) {
|
|
36
|
+
const original = target[prop];
|
|
37
|
+
if (typeof original === 'function') {
|
|
38
|
+
return function (column, ...args) {
|
|
39
|
+
const transformed = relq[methods_1.INTERNAL].transformToDbColumns(tableName, { [column]: true });
|
|
40
|
+
const dbColumn = Object.keys(transformed)[0] || column;
|
|
41
|
+
const result = original.call(target, dbColumn, ...args);
|
|
42
|
+
if (result === target || (result && typeof result === 'object')) {
|
|
43
|
+
return createProxy(result);
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return original;
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
return createProxy(originalBuilder);
|
|
46
53
|
}
|
|
47
54
|
toString() {
|
|
48
55
|
return this.builder.toString();
|
|
@@ -27,19 +27,26 @@ export class ConnectedCountBuilder {
|
|
|
27
27
|
wrapConditionBuilder(originalBuilder) {
|
|
28
28
|
const relq = this.relq;
|
|
29
29
|
const tableName = this.tableName;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
const createProxy = (target) => {
|
|
31
|
+
return new Proxy(target, {
|
|
32
|
+
get(target, prop) {
|
|
33
|
+
const original = target[prop];
|
|
34
|
+
if (typeof original === 'function') {
|
|
35
|
+
return function (column, ...args) {
|
|
36
|
+
const transformed = relq[INTERNAL].transformToDbColumns(tableName, { [column]: true });
|
|
37
|
+
const dbColumn = Object.keys(transformed)[0] || column;
|
|
38
|
+
const result = original.call(target, dbColumn, ...args);
|
|
39
|
+
if (result === target || (result && typeof result === 'object')) {
|
|
40
|
+
return createProxy(result);
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return original;
|
|
39
46
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
return createProxy(originalBuilder);
|
|
43
50
|
}
|
|
44
51
|
toString() {
|
|
45
52
|
return this.builder.toString();
|
package/dist/index.d.ts
CHANGED
|
@@ -6592,7 +6592,7 @@ declare class ConnectedCountBuilder<TTable = any, TGroups extends Record<string,
|
|
|
6592
6592
|
* - If no groups: returns number (count)
|
|
6593
6593
|
* - If groups: returns typed object { groupName: value }
|
|
6594
6594
|
*/
|
|
6595
|
-
get(): Promise<keyof TGroups extends never ? number : TGroups
|
|
6595
|
+
get(): Promise<keyof TGroups extends never ? number : Prettify<TGroups>>;
|
|
6596
6596
|
}
|
|
6597
6597
|
declare class ReturningExecutor<TResult> {
|
|
6598
6598
|
private builder;
|