albedo-node 0.8.1 → 0.8.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.
package/README.md CHANGED
@@ -75,6 +75,47 @@ bucket.close();
75
75
 
76
76
  You can chain multiple `where` calls or combine them with `sortBy` and `sector`. For quick one-off predicates, the standalone `where(field, filter)` helper returns a `Query` instance that slots into any method accepting a query.
77
77
 
78
+ Logical groups are available as both instance methods and static constructors:
79
+
80
+ ```ts
81
+ import { Query, where } from "albedo-node";
82
+
83
+ const visibleUsers = Query.or(
84
+ where("role", "admin"),
85
+ Query.and(
86
+ where("role", "user"),
87
+ where("verified", true),
88
+ ),
89
+ ).nor(
90
+ where("deleted", true),
91
+ );
92
+
93
+ for (const doc of bucket.list(visibleUsers)) {
94
+ console.log(doc);
95
+ }
96
+ ```
97
+
98
+ This produces a query equivalent to:
99
+
100
+ ```ts
101
+ {
102
+ query: {
103
+ $or: [
104
+ { role: "admin" },
105
+ {
106
+ $and: [
107
+ { role: "user" },
108
+ { verified: true },
109
+ ],
110
+ },
111
+ ],
112
+ $nor: [
113
+ { deleted: true },
114
+ ],
115
+ },
116
+ }
117
+ ```
118
+
78
119
  ### Transforming documents in place
79
120
 
80
121
  ```ts
@@ -173,8 +214,22 @@ Regardless of which form you use, the structure mirrors the underlying Albedo qu
173
214
 
174
215
  - `{ query: { field: value } }` — equality filters
175
216
  - `{ query: { age: { "$gt": 40 } } }` — comparison operators
217
+ - `{ query: { $or: [{ role: "admin" }, { public: true }], deleted: false } }` — logical groups mixed with leaf filters
176
218
  - `{ query: { _id: someId }, sector: { limit: 10, offset: 0 } }` — pagination controls
177
219
 
220
+ Supported field operators in this binding include:
221
+
222
+ - `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`
223
+ - `$in`, `$between`
224
+ - `$startsWith`, `$endsWith`
225
+ - `$exists`, `$notExists`
226
+
227
+ Logical operators supported inside `query` are:
228
+
229
+ - `$or`
230
+ - `$and`
231
+ - `$nor`
232
+
178
233
  For the exhaustive list of operators and document shapes, consult the [Albedo Query reference](https://github.com/klirix/albedo#readme). Whatever BSON document the core engine accepts can be provided here either as a plain object or as prebuilt BSON bytes.
179
234
 
180
235
  ### ObjectId support
@@ -232,8 +287,14 @@ Serialized documents that contain `_id` fields with a BSON ObjectId will be revi
232
287
 
233
288
  - `Query`
234
289
  - `where(field, filter)` chains field predicates (e.g. `{ $eq: value }`, `{ $gt: 10 }`)
290
+ - `or(...clauses)` adds an `$or` group
291
+ - `and(...clauses)` adds an `$and` group
292
+ - `nor(...clauses)` adds a `$nor` group
235
293
  - `sortBy(field, direction?)` sets sort order
236
294
  - `sector(offset?, limit?)` applies pagination window
295
+ - `static or(...clauses): Query` creates a query with an `$or` group
296
+ - `static and(...clauses): Query` creates a query with an `$and` group
297
+ - `static nor(...clauses): Query` creates a query with a `$nor` group
237
298
 
238
299
  - `where(field, filter): Query` — convenience helper that creates a single-field `Query`
239
300
 
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "albedo-node",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "High-performance embedded database for Node.js with native bindings, BSON support, indexing, and replication",
5
5
  "keywords": [
6
6
  "albedo",