@loomcore/api 0.0.1 → 0.0.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.
@@ -160,6 +160,19 @@ function buildMongoMatchFromQueryOptions(queryOptions) {
160
160
  match[key] = value.eq;
161
161
  }
162
162
  }
163
+ else if (value.in !== undefined && Array.isArray(value.in)) {
164
+ if (key.endsWith('Id') && !PROPERTIES_THAT_ARE_NOT_OBJECT_IDS.includes(key)) {
165
+ const objectIds = value.in
166
+ .filter(val => typeof val === 'string' && entityUtils.isValidObjectId(val))
167
+ .map(val => new ObjectId(val));
168
+ if (objectIds.length > 0) {
169
+ match[key] = { $in: objectIds };
170
+ }
171
+ }
172
+ else {
173
+ match[key] = { $in: value.in };
174
+ }
175
+ }
163
176
  else if (value.gte !== undefined) {
164
177
  match[key] = { $gte: value.gte };
165
178
  }
@@ -199,6 +212,11 @@ function addKeyValueToWhereClause(whereClause, key, value, tableAlias = '') {
199
212
  formattedValue = formatValue(value.eq);
200
213
  operator = '=';
201
214
  }
215
+ else if (value.in !== undefined && Array.isArray(value.in)) {
216
+ const formattedValues = value.in.map(val => formatValue(val)).join(', ');
217
+ formattedValue = `(${formattedValues})`;
218
+ operator = 'IN';
219
+ }
202
220
  else if (value.gte !== undefined) {
203
221
  formattedValue = formatValue(value.gte);
204
222
  operator = '>=';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb",
6
6
  "scripts": {
@@ -16,7 +16,6 @@
16
16
  "update-lib-versions": "npx --yes npm-check-updates -u -f @loomcore/models",
17
17
  "install-updated-libs": "npm i @loomcore/models",
18
18
  "update-libs": "npm-run-all -s update-lib-versions install-updated-libs",
19
-
20
19
  "typecheck": "tsc",
21
20
  "test": "cross-env NODE_ENV=test vitest run",
22
21
  "test:ci": "cross-env NODE_ENV=test vitest run --reporter=json --outputFile=test-results.json",
@@ -45,7 +44,7 @@
45
44
  "jsonwebtoken": "^9.0.2"
46
45
  },
47
46
  "peerDependencies": {
48
- "@loomcore/common": "^0.0.6",
47
+ "@loomcore/common": "^0.0.7",
49
48
  "@sinclair/typebox": "^0.34.31",
50
49
  "cookie-parser": "^1.4.6",
51
50
  "express": "^5.1.0",