@thi.ng/oquery 2.3.27 → 2.3.29

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/README.md +34 -10
  3. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2025-07-10T14:20:23Z
3
+ - **Last updated**: 2025-07-20T14:56:01Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
package/README.md CHANGED
@@ -139,7 +139,7 @@ Object queries expect an object of the following structure:
139
139
 
140
140
  A concrete example:
141
141
 
142
- ```ts tangle:export/readme.ts
142
+ ```ts id:db
143
143
  const DB = {
144
144
  alice: {
145
145
  age: 33,
@@ -167,11 +167,16 @@ To find all answers for the question: Who knows Bob?
167
167
  ```ts tangle:export/readme.ts
168
168
  import { defQuery } from "@thi.ng/oquery";
169
169
 
170
+ // include above DB definition
171
+ <<db>>
172
+
170
173
  // create query w/ custom options
171
174
  // (options explained further below...)
172
175
  const q = defQuery({ partial: true });
173
176
 
174
- console.log(q(DB, null, "knows", "bob"));
177
+ console.log(
178
+ q(DB, null, "knows", "bob")
179
+ );
175
180
  // {
176
181
  // alice: { knows: [ 'bob' ] },
177
182
  // charlie: { knows: [ 'bob' ] },
@@ -205,7 +210,9 @@ table above.
205
210
 
206
211
  ```ts tangle:export/readme.ts
207
212
  // Who does Alice know?
208
- q(DB, "alice", "knows", null)
213
+ console.log(
214
+ q(DB, "alice", "knows", null)
215
+ );
209
216
  // { alice: { knows: [ 'bob', 'charlie', 'dori' ] } }
210
217
  ```
211
218
 
@@ -215,7 +222,9 @@ terms).
215
222
 
216
223
  ```ts tangle:export/readme.ts
217
224
  // Anyone with initial "A" knows Charlie?
218
- q(DB, (s) => s[0] === "a", "knows", "charlie")
225
+ console.log(
226
+ q(DB, (s) => s[0] === "a", "knows", "charlie")
227
+ );
219
228
  // { alice: { knows: [ 'charlie' ] } }
220
229
  ```
221
230
 
@@ -232,7 +241,9 @@ const DBALT: Person[] = [
232
241
  { id: "charlie", knows: ["alice","bob","dori"] },
233
242
  ];
234
243
 
235
- defQuery<Person[]>()(DBALT, "knows", "alice")
244
+ console.log(
245
+ defQuery<Person[]>()(DBALT, "knows", "alice")
246
+ );
236
247
  // [
237
248
  // { id: 'bob', knows: [ 'alice' ] },
238
249
  // { id: 'charlie', knows: [ 'alice', 'bob', 'dori' ] }
@@ -247,19 +258,28 @@ above](#query-patterns)...
247
258
  ```ts tangle:export/readme2.ts
248
259
  import { defQuery } from "@thi.ng/oquery";
249
260
 
261
+ // include above DB definition
262
+ <<db>>
263
+
250
264
  // using partial result objects option for brevity here
251
265
  const q = defQuery({ partial: true });
252
266
 
253
267
  // find all subjects with `type = "person"` relationship
254
- q(DB, null, "type", "person");
268
+ console.log(
269
+ q(DB, null, "type", "person")
270
+ );
255
271
  // { alice: { type: 'person' }, bob: { type: 'person' } }
256
272
 
257
273
  // everyone w/ given min age
258
- q(DB, null, "age", (age) => age >= 33)
274
+ console.log(
275
+ q(DB, null, "age", (age: number) => age >= 33)
276
+ );
259
277
  // { alice: { age: 33 } }
260
278
 
261
279
  // select only subjects with A/B initials
262
- q(DB, (id) => id >= "a" && id < "c", null, null)
280
+ console.log(
281
+ q(DB, (id) => id >= "a" && id < "c", null, null)
282
+ );
263
283
  // {
264
284
  // alice: { age: 33, knows: [ 'bob', 'charlie', 'dori' ], type: 'person' },
265
285
  // bob: { age: 32, knows: [ 'alice' ], type: 'person', spouse: 'alice' }
@@ -272,7 +292,9 @@ Union vs. intersection queries:
272
292
  const union = defQuery();
273
293
 
274
294
  // who knows bob OR charlie?
275
- union(DB, null, "knows", ["bob", "charlie"]);
295
+ console.log(
296
+ union(DB, null, "knows", ["bob", "charlie"])
297
+ );
276
298
  // {
277
299
  // alice: { age: 33, knows: [ 'bob', 'charlie', 'dori' ], type: 'person' },
278
300
  // charlie: { parent: 'alice', knows: [ 'alice', 'bob', 'dori' ] },
@@ -282,7 +304,9 @@ union(DB, null, "knows", ["bob", "charlie"]);
282
304
  const isec = defQuery({ intersect: true });
283
305
 
284
306
  // who knows bob AND charlie?
285
- isec(DB, null, "knows", ["bob", "charlie"]);
307
+ console.log(
308
+ isec(DB, null, "knows", ["bob", "charlie"])
309
+ );
286
310
  // {
287
311
  // alice: { age: 33, knows: [ 'bob', 'charlie', 'dori' ], type: 'person' }
288
312
  // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/oquery",
3
- "version": "2.3.27",
3
+ "version": "2.3.29",
4
4
  "description": "Datalog-inspired, optimized pattern/predicate query engine for JS objects & arrays of objects",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -39,14 +39,14 @@
39
39
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@thi.ng/api": "^8.11.30",
43
- "@thi.ng/checks": "^3.7.10",
44
- "@thi.ng/compare": "^2.4.22",
45
- "@thi.ng/defmulti": "^3.0.70",
46
- "@thi.ng/equiv": "^2.1.86"
42
+ "@thi.ng/api": "^8.11.31",
43
+ "@thi.ng/checks": "^3.7.11",
44
+ "@thi.ng/compare": "^2.4.23",
45
+ "@thi.ng/defmulti": "^3.0.71",
46
+ "@thi.ng/equiv": "^2.1.87"
47
47
  },
48
48
  "devDependencies": {
49
- "esbuild": "^0.25.6",
49
+ "esbuild": "^0.25.8",
50
50
  "typedoc": "^0.28.7",
51
51
  "typescript": "^5.8.3"
52
52
  },
@@ -99,5 +99,5 @@
99
99
  ],
100
100
  "year": 2020
101
101
  },
102
- "gitHead": "56d8f088389b22192a06e9a395b5eecebf47697a\n"
102
+ "gitHead": "3cd1bea8b2bf6b859609f6d5c14b4eb64745681f\n"
103
103
  }