@dwtechs/antity-pgsql 0.15.0 → 0.15.2

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.
@@ -108,6 +108,7 @@ function index(index, matchMode) {
108
108
  const i = index.map((i) => `$${i}`);
109
109
  switch (matchMode) {
110
110
  case "in":
111
+ case "notIn":
111
112
  return `(${i})`;
112
113
  default:
113
114
  return `${i}`;
@@ -130,6 +131,8 @@ function comparator(matchMode) {
130
131
  return "<>";
131
132
  case "in":
132
133
  return "IN";
134
+ case "notIn":
135
+ return "NOT IN";
133
136
  case "lt":
134
137
  return "<";
135
138
  case "lte":
@@ -166,6 +169,15 @@ function formatValue(value, matchMode) {
166
169
  return value;
167
170
  }
168
171
  }
172
+ function shouldSkipValue(value, matchMode) {
173
+ if (isString(value, "0"))
174
+ return true;
175
+ if (isArray(value, "0"))
176
+ return true;
177
+ if (value === null && matchMode !== 'is' && matchMode !== 'isNot')
178
+ return true;
179
+ return false;
180
+ }
169
181
  function add(filters) {
170
182
  var _a, _b;
171
183
  const conditions = [];
@@ -178,6 +190,8 @@ function add(filters) {
178
190
  const groupConditions = [];
179
191
  for (const filter of filterArray) {
180
192
  const { value, matchMode } = filter;
193
+ if (shouldSkipValue(value, matchMode))
194
+ continue;
181
195
  const indexes = isArray(value) ? value.map(() => i++) : [i++];
182
196
  const cond = addOne(k, indexes, matchMode);
183
197
  if (cond) {
@@ -560,8 +574,8 @@ function type(type) {
560
574
  }
561
575
 
562
576
  const matchModes = {
563
- string: ["startsWith", "contains", "endsWith", "notContains", "equals", "notEquals", "lt", "lte", "gt", "gte"],
564
- number: ["equals", "notEquals", "lt", "lte", "gt", "gte"],
577
+ string: ["startsWith", "contains", "endsWith", "notContains", "equals", "notEquals", "lt", "lte", "gt", "gte", "in", "notIn"],
578
+ number: ["equals", "notEquals", "lt", "lte", "gt", "gte", "in", "notIn"],
565
579
  date: ["is", "isNot", "dateAfter"],
566
580
  };
567
581
  function matchMode(type, matchMode) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dwtechs/antity-pgsql",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "Open source library to add PostgreSQL support to @dwtechs/Antity entities.",
5
5
  "keywords": [
6
6
  "entities"