@snowtop/ent 0.1.0-alpha61 → 0.1.0-alpha63
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 +12 -0
- package/core/clause.js +35 -14
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +1 -1
package/core/clause.d.ts
CHANGED
|
@@ -56,6 +56,18 @@ export declare function PostgresArrayNotContainsValue(col: string, value: any):
|
|
|
56
56
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
57
57
|
*/
|
|
58
58
|
export declare function PostgresArrayNotContains(col: string, value: any[]): Clause;
|
|
59
|
+
/**
|
|
60
|
+
* creates a clause to determine if the arrays overlap, that is, do they have any elements in common
|
|
61
|
+
* only works with postgres gin indexes
|
|
62
|
+
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
63
|
+
*/
|
|
64
|
+
export declare function PostgresArrayOverlaps(col: string, value: any[]): Clause;
|
|
65
|
+
/**
|
|
66
|
+
* creates a clause to determine if the arrays do not overlap, that is, do they have any elements in common
|
|
67
|
+
* only works with postgres gin indexes
|
|
68
|
+
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
69
|
+
*/
|
|
70
|
+
export declare function PostgresArrayNotOverlaps(col: string, value: any[]): Clause;
|
|
59
71
|
/**
|
|
60
72
|
* @deprecated use PostgresArrayContainsValue
|
|
61
73
|
*/
|
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.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.In = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayNotEq = exports.ArrayEq = exports.PostgresArrayNotContains = exports.PostgresArrayNotContainsValue = exports.PostgresArrayContains = exports.PostgresArrayContainsValue = void 0;
|
|
22
|
+
exports.sensitiveValue = exports.TsVectorWebsearchToTsQuery = exports.TsVectorPhraseToTsQuery = exports.TsVectorPlainToTsQuery = exports.TsVectorColTsQuery = exports.WebsearchToTsQuery = exports.PhraseToTsQuery = exports.PlainToTsQuery = exports.TsQuery = exports.In = exports.Or = exports.AndOptional = exports.And = exports.LessEq = exports.GreaterEq = exports.Less = exports.Greater = exports.NotEq = exports.Eq = exports.ArrayNotEq = exports.ArrayEq = exports.PostgresArrayNotOverlaps = exports.PostgresArrayOverlaps = exports.PostgresArrayNotContains = exports.PostgresArrayNotContainsValue = exports.PostgresArrayContains = exports.PostgresArrayContainsValue = void 0;
|
|
23
23
|
const db_1 = __importStar(require("./db"));
|
|
24
24
|
function isSensitive(val) {
|
|
25
25
|
return (val !== null &&
|
|
@@ -157,18 +157,19 @@ class arraySimpleClause {
|
|
|
157
157
|
return `${this.col}${this.op}${rawValue(this.value)}`;
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
class
|
|
161
|
-
constructor(col, value, not) {
|
|
160
|
+
class postgresArrayOperator {
|
|
161
|
+
constructor(col, value, op, not) {
|
|
162
162
|
this.col = col;
|
|
163
163
|
this.value = value;
|
|
164
|
+
this.op = op;
|
|
164
165
|
this.not = not;
|
|
165
166
|
}
|
|
166
167
|
clause(idx) {
|
|
167
168
|
if (db_1.default.getDialect() === db_1.Dialect.Postgres) {
|
|
168
169
|
if (this.not) {
|
|
169
|
-
return `NOT ${this.col}
|
|
170
|
+
return `NOT ${this.col} ${this.op} $${idx}`;
|
|
170
171
|
}
|
|
171
|
-
return `${this.col}
|
|
172
|
+
return `${this.col} ${this.op} $${idx}`;
|
|
172
173
|
}
|
|
173
174
|
throw new Error(`not supported`);
|
|
174
175
|
}
|
|
@@ -189,14 +190,14 @@ class postgresArrayContains {
|
|
|
189
190
|
}
|
|
190
191
|
instanceKey() {
|
|
191
192
|
if (this.not) {
|
|
192
|
-
return `NOT:${this.col}
|
|
193
|
+
return `NOT:${this.col}${this.op}${rawValue(this.value)}`;
|
|
193
194
|
}
|
|
194
|
-
return `${this.col}
|
|
195
|
+
return `${this.col}${this.op}${rawValue(this.value)}`;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
|
-
class
|
|
198
|
-
constructor(col, value, not) {
|
|
199
|
-
super(col, value, not);
|
|
198
|
+
class postgresArrayOperatorList extends postgresArrayOperator {
|
|
199
|
+
constructor(col, value, op, not) {
|
|
200
|
+
super(col, value, op, not);
|
|
200
201
|
}
|
|
201
202
|
values() {
|
|
202
203
|
return [
|
|
@@ -374,13 +375,15 @@ class websearchTosQueryClause extends tsQueryClause {
|
|
|
374
375
|
return "websearch_to_tsquery";
|
|
375
376
|
}
|
|
376
377
|
}
|
|
378
|
+
// postgres array operators
|
|
379
|
+
// https://www.postgresql.org/docs/current/functions-array.html
|
|
377
380
|
/**
|
|
378
381
|
* creates a clause to determine if the given value is contained in the array stored in the column in the db
|
|
379
382
|
* only works with postgres gin indexes
|
|
380
383
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
381
384
|
*/
|
|
382
385
|
function PostgresArrayContainsValue(col, value) {
|
|
383
|
-
return new
|
|
386
|
+
return new postgresArrayOperator(col, value, "@>");
|
|
384
387
|
}
|
|
385
388
|
exports.PostgresArrayContainsValue = PostgresArrayContainsValue;
|
|
386
389
|
/**
|
|
@@ -389,7 +392,7 @@ exports.PostgresArrayContainsValue = PostgresArrayContainsValue;
|
|
|
389
392
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
390
393
|
*/
|
|
391
394
|
function PostgresArrayContains(col, value) {
|
|
392
|
-
return new
|
|
395
|
+
return new postgresArrayOperatorList(col, value, "@>");
|
|
393
396
|
}
|
|
394
397
|
exports.PostgresArrayContains = PostgresArrayContains;
|
|
395
398
|
/**
|
|
@@ -398,7 +401,7 @@ exports.PostgresArrayContains = PostgresArrayContains;
|
|
|
398
401
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
399
402
|
*/
|
|
400
403
|
function PostgresArrayNotContainsValue(col, value) {
|
|
401
|
-
return new
|
|
404
|
+
return new postgresArrayOperator(col, value, "@>", true);
|
|
402
405
|
}
|
|
403
406
|
exports.PostgresArrayNotContainsValue = PostgresArrayNotContainsValue;
|
|
404
407
|
/**
|
|
@@ -407,9 +410,27 @@ exports.PostgresArrayNotContainsValue = PostgresArrayNotContainsValue;
|
|
|
407
410
|
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
408
411
|
*/
|
|
409
412
|
function PostgresArrayNotContains(col, value) {
|
|
410
|
-
return new
|
|
413
|
+
return new postgresArrayOperatorList(col, value, "@>", true);
|
|
411
414
|
}
|
|
412
415
|
exports.PostgresArrayNotContains = PostgresArrayNotContains;
|
|
416
|
+
/**
|
|
417
|
+
* creates a clause to determine if the arrays overlap, that is, do they have any elements in common
|
|
418
|
+
* only works with postgres gin indexes
|
|
419
|
+
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
420
|
+
*/
|
|
421
|
+
function PostgresArrayOverlaps(col, value) {
|
|
422
|
+
return new postgresArrayOperatorList(col, value, "&&");
|
|
423
|
+
}
|
|
424
|
+
exports.PostgresArrayOverlaps = PostgresArrayOverlaps;
|
|
425
|
+
/**
|
|
426
|
+
* creates a clause to determine if the arrays do not overlap, that is, do they have any elements in common
|
|
427
|
+
* only works with postgres gin indexes
|
|
428
|
+
* https://www.postgresql.org/docs/current/indexes-types.html#INDEXES-TYPES-GIN
|
|
429
|
+
*/
|
|
430
|
+
function PostgresArrayNotOverlaps(col, value) {
|
|
431
|
+
return new postgresArrayOperatorList(col, value, "&&", true);
|
|
432
|
+
}
|
|
433
|
+
exports.PostgresArrayNotOverlaps = PostgresArrayNotOverlaps;
|
|
413
434
|
/**
|
|
414
435
|
* @deprecated use PostgresArrayContainsValue
|
|
415
436
|
*/
|
package/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ declare const query: {
|
|
|
24
24
|
PostgresArrayContains: typeof q.PostgresArrayContains;
|
|
25
25
|
PostgresArrayNotContainsValue: typeof q.PostgresArrayNotContainsValue;
|
|
26
26
|
PostgresArrayNotContains: typeof q.PostgresArrayNotContains;
|
|
27
|
+
PostgresArrayOverlaps: typeof q.PostgresArrayOverlaps;
|
|
28
|
+
PostgresArrayNotOverlaps: typeof q.PostgresArrayNotOverlaps;
|
|
27
29
|
TsQuery: typeof q.TsQuery;
|
|
28
30
|
PlainToTsQuery: typeof q.PlainToTsQuery;
|
|
29
31
|
PhraseToTsQuery: typeof q.PhraseToTsQuery;
|
package/index.js
CHANGED
|
@@ -121,6 +121,8 @@ const query = {
|
|
|
121
121
|
PostgresArrayContains: q.PostgresArrayContains,
|
|
122
122
|
PostgresArrayNotContainsValue: q.PostgresArrayNotContainsValue,
|
|
123
123
|
PostgresArrayNotContains: q.PostgresArrayNotContains,
|
|
124
|
+
PostgresArrayOverlaps: q.PostgresArrayOverlaps,
|
|
125
|
+
PostgresArrayNotOverlaps: q.PostgresArrayNotOverlaps,
|
|
124
126
|
TsQuery: q.TsQuery,
|
|
125
127
|
PlainToTsQuery: q.PlainToTsQuery,
|
|
126
128
|
PhraseToTsQuery: q.PhraseToTsQuery,
|