@dwtechs/antity-pgsql 0.17.5 → 0.17.6

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/README.md CHANGED
@@ -152,7 +152,7 @@ type Row = Record<string, string | number | boolean | Date | number[]>;
152
152
 
153
153
  type Comparator =
154
154
  "=" | "<" | ">" | "<=" | ">=" | "<>" |
155
- "IS" | "IS NOT" | "IN" | "NOT IN" | "LIKE" | "NOT LIKE";
155
+ "IS" | "IS NOT" | "IN" | "NOT IN" | "LIKE" | "NOT LIKE" | "&&";
156
156
 
157
157
  type MatchMode =
158
158
  "startsWith" |
@@ -164,6 +164,7 @@ type MatchMode =
164
164
  "between" |
165
165
  "in" |
166
166
  "notIn" |
167
+ "&&" | // array overlap — use with array-typed columns; generates: column && ARRAY[$1,$2]
167
168
  "lt" |
168
169
  "lte" |
169
170
  "gt" |
@@ -60,9 +60,9 @@ export declare class Property extends BaseProperty {
60
60
  }
61
61
 
62
62
  export type LogicalOperator = "AND" | "OR";
63
- export type Comparator = "=" | "<" | ">" | "<=" | ">=" | "<>" | "IS" | "IS NOT" | "IN" | "NOT IN" | "LIKE" | "NOT LIKE";
64
- export type MatchMode = "startsWith" | "endsWith" | "contains" | "notContains" | "equals" | "notEquals" | "between" | "in" | "notIn" | "lt" | "lte" | "gt" | "gte" | "is" | "isNot" | "before" | "after" | "st_contains" | "st_dwithin" | Comparator;
65
- export type MappedType = "string" | "number" | "date";
63
+ export type Comparator = "=" | "<" | ">" | "<=" | ">=" | "<>" | "IS" | "IS NOT" | "IN" | "NOT IN" | "LIKE" | "NOT LIKE" | "&&";
64
+ export type MatchMode = "startsWith" | "endsWith" | "contains" | "notContains" | "equals" | "notEquals" | "between" | "in" | "notIn" | "&&" | "lt" | "lte" | "gt" | "gte" | "is" | "isNot" | "before" | "after" | "st_contains" | "st_dwithin" | Comparator;
65
+ export type MappedType = "string" | "number" | "date" | "array";
66
66
  export type Geometry = {
67
67
  lng: number;
68
68
  lat: number;
@@ -112,12 +112,14 @@ function index(index, matchMode) {
112
112
  case "IN":
113
113
  case "NOT IN":
114
114
  return `(${i})`;
115
+ case "&&":
116
+ return `ARRAY[${i}]`;
115
117
  default:
116
118
  return `${i}`;
117
119
  }
118
120
  }
119
121
 
120
- const COMPARATORS = new Set(["=", "<", ">", "<=", ">=", "<>", "IS", "IS NOT", "IN", "NOT IN", "LIKE", "NOT LIKE"]);
122
+ const COMPARATORS = new Set(["=", "<", ">", "<=", ">=", "<>", "IS", "IS NOT", "IN", "NOT IN", "LIKE", "NOT LIKE", "&&"]);
121
123
  function comparator(matchMode) {
122
124
  if (matchMode && COMPARATORS.has(matchMode))
123
125
  return matchMode;
@@ -154,6 +156,8 @@ function comparator(matchMode) {
154
156
  return "<";
155
157
  case "after":
156
158
  return ">";
159
+ case "&&":
160
+ return "&&";
157
161
  default:
158
162
  return null;
159
163
  }
@@ -524,6 +528,8 @@ function type(type) {
524
528
  return s;
525
529
  case "object":
526
530
  return s;
531
+ case "array":
532
+ return "array";
527
533
  default:
528
534
  return s;
529
535
  }
@@ -533,6 +539,7 @@ const matchModes = {
533
539
  string: new Set(["startsWith", "contains", "endsWith", "notContains", "equals", "notEquals", "lt", "lte", "gt", "gte", "in", "notIn"]),
534
540
  number: new Set(["equals", "notEquals", "lt", "lte", "gt", "gte", "in", "notIn"]),
535
541
  date: new Set(["is", "isNot", "dateAfter"]),
542
+ array: new Set(["&&"]),
536
543
  };
537
544
  function matchMode(type, matchMode) {
538
545
  return COMPARATORS.has(matchMode) || matchModes[type].has(matchMode);
@@ -555,6 +562,12 @@ function cleanFilters(filters, properties) {
555
562
  const type$1 = type(prop.type);
556
563
  const filterValue = filters[k];
557
564
  const filterArray = isArray(filterValue) ? filterValue : [filterValue];
565
+ if (type$1 === "array") {
566
+ for (const f of filterArray) {
567
+ if (f.matchMode === "in")
568
+ f.matchMode = "&&";
569
+ }
570
+ }
558
571
  const validFilters = filterArray.filter((f) => {
559
572
  const { matchMode: matchMode$1 } = f;
560
573
  if (!matchMode$1 || !matchMode(type$1, matchMode$1)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwtechs/antity-pgsql",
3
- "version": "0.17.5",
3
+ "version": "0.17.6",
4
4
  "description": "Open source library to add PostgreSQL support to @dwtechs/Antity entities.",
5
5
  "keywords": [
6
6
  "entities"