@snowtop/ent 0.0.39-alpha6 → 0.0.39-alpha7
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.
- package/core/clause.d.ts +6 -0
- package/core/clause.js +54 -1
- package/index.d.ts +6 -0
- package/index.js +6 -0
- package/package.json +1 -1
package/core/clause.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ declare class compositeClause implements Clause {
|
|
|
29
29
|
logValues(): any[];
|
|
30
30
|
instanceKey(): string;
|
|
31
31
|
}
|
|
32
|
+
export declare function ArrayEq(col: string, value: any): Clause;
|
|
33
|
+
export declare function ArrayNotEq(col: string, value: any): Clause;
|
|
34
|
+
export declare function ArrayGreater(col: string, value: any): Clause;
|
|
35
|
+
export declare function ArrayLess(col: string, value: any): Clause;
|
|
36
|
+
export declare function ArrayGreaterEq(col: string, value: any): Clause;
|
|
37
|
+
export declare function ArrayLessEq(col: string, value: any): Clause;
|
|
32
38
|
export declare function Eq(col: string, value: any): Clause;
|
|
33
39
|
export declare function NotEq(col: string, value: any): Clause;
|
|
34
40
|
export declare function Greater(col: string, value: any): simpleClause;
|
package/core/clause.js
CHANGED
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.sensitiveValue = exports.In = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = void 0;
|
|
22
|
+
exports.sensitiveValue = exports.In = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayLessEq = exports.ArrayGreaterEq = exports.ArrayLess = exports.ArrayGreater = exports.ArrayNotEq = exports.ArrayEq = void 0;
|
|
23
23
|
const db_1 = __importStar(require("./db"));
|
|
24
24
|
function isSensitive(val) {
|
|
25
25
|
return (val !== null &&
|
|
@@ -120,6 +120,34 @@ class isNotNullClause {
|
|
|
120
120
|
return `${this.col} IS NOT NULL`;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
+
class arraySimpleClause {
|
|
124
|
+
constructor(col, value, op) {
|
|
125
|
+
this.col = col;
|
|
126
|
+
this.value = value;
|
|
127
|
+
this.op = op;
|
|
128
|
+
}
|
|
129
|
+
clause(idx) {
|
|
130
|
+
if (db_1.default.getDialect() === db_1.Dialect.Postgres) {
|
|
131
|
+
return `$${idx} ${this.op} ANY(${this.col})`;
|
|
132
|
+
}
|
|
133
|
+
return `${this.col} ${this.op} ?`;
|
|
134
|
+
}
|
|
135
|
+
values() {
|
|
136
|
+
if (isSensitive(this.value)) {
|
|
137
|
+
return [this.value.value()];
|
|
138
|
+
}
|
|
139
|
+
return [this.value];
|
|
140
|
+
}
|
|
141
|
+
logValues() {
|
|
142
|
+
if (isSensitive(this.value)) {
|
|
143
|
+
return [this.value.logValue()];
|
|
144
|
+
}
|
|
145
|
+
return [this.value];
|
|
146
|
+
}
|
|
147
|
+
instanceKey() {
|
|
148
|
+
return `${this.col}${this.op}${rawValue(this.value)}`;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
123
151
|
class inClause {
|
|
124
152
|
constructor(col, value) {
|
|
125
153
|
this.col = col;
|
|
@@ -207,6 +235,31 @@ class compositeClause {
|
|
|
207
235
|
return keys.join(this.sep);
|
|
208
236
|
}
|
|
209
237
|
}
|
|
238
|
+
// TODO we need to check sqlite version...
|
|
239
|
+
function ArrayEq(col, value) {
|
|
240
|
+
return new arraySimpleClause(col, value, "=");
|
|
241
|
+
}
|
|
242
|
+
exports.ArrayEq = ArrayEq;
|
|
243
|
+
function ArrayNotEq(col, value) {
|
|
244
|
+
return new arraySimpleClause(col, value, "!=");
|
|
245
|
+
}
|
|
246
|
+
exports.ArrayNotEq = ArrayNotEq;
|
|
247
|
+
function ArrayGreater(col, value) {
|
|
248
|
+
return new arraySimpleClause(col, value, ">");
|
|
249
|
+
}
|
|
250
|
+
exports.ArrayGreater = ArrayGreater;
|
|
251
|
+
function ArrayLess(col, value) {
|
|
252
|
+
return new arraySimpleClause(col, value, "<");
|
|
253
|
+
}
|
|
254
|
+
exports.ArrayLess = ArrayLess;
|
|
255
|
+
function ArrayGreaterEq(col, value) {
|
|
256
|
+
return new arraySimpleClause(col, value, ">=");
|
|
257
|
+
}
|
|
258
|
+
exports.ArrayGreaterEq = ArrayGreaterEq;
|
|
259
|
+
function ArrayLessEq(col, value) {
|
|
260
|
+
return new arraySimpleClause(col, value, "<=");
|
|
261
|
+
}
|
|
262
|
+
exports.ArrayLessEq = ArrayLessEq;
|
|
210
263
|
function Eq(col, value) {
|
|
211
264
|
return new simpleClause(col, value, "=", new isNullClause(col));
|
|
212
265
|
}
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ declare const query: {
|
|
|
18
18
|
Less: typeof q.Less;
|
|
19
19
|
GreaterEq: typeof q.GreaterEq;
|
|
20
20
|
LessEq: typeof q.LessEq;
|
|
21
|
+
ArrayEq: typeof q.ArrayEq;
|
|
22
|
+
ArrayNotEq: typeof q.ArrayNotEq;
|
|
23
|
+
ArrayGreater: typeof q.ArrayGreater;
|
|
24
|
+
ArrayLess: typeof q.ArrayLess;
|
|
25
|
+
ArrayGreaterEq: typeof q.ArrayGreaterEq;
|
|
26
|
+
ArrayLessEq: typeof q.ArrayLessEq;
|
|
21
27
|
};
|
|
22
28
|
export { query };
|
|
23
29
|
export { RequestContext, ContextCache } from "./core/context";
|
package/index.js
CHANGED
|
@@ -116,6 +116,12 @@ const query = {
|
|
|
116
116
|
Less: q.Less,
|
|
117
117
|
GreaterEq: q.GreaterEq,
|
|
118
118
|
LessEq: q.LessEq,
|
|
119
|
+
ArrayEq: q.ArrayEq,
|
|
120
|
+
ArrayNotEq: q.ArrayNotEq,
|
|
121
|
+
ArrayGreater: q.ArrayGreater,
|
|
122
|
+
ArrayLess: q.ArrayLess,
|
|
123
|
+
ArrayGreaterEq: q.ArrayGreaterEq,
|
|
124
|
+
ArrayLessEq: q.ArrayLessEq,
|
|
119
125
|
};
|
|
120
126
|
exports.query = query;
|
|
121
127
|
var context_1 = require("./core/context");
|