@cero-base/cero 0.8.9 → 0.8.10

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 (2) hide show
  1. package/README.md +24 -4
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -85,6 +85,15 @@ const recovered = await cero.restore(me, 'twelve words …')
85
85
  | `{ … }` (plain object) | a child handle — its own scope, share by invite |
86
86
  | `local: { … }` | device-only — never leaves this device |
87
87
 
88
+ A collection can declare **secondary indexes** for fast exact-field lookups:
89
+
90
+ ```js
91
+ cero.t.collection(
92
+ { text: cero.t.string },
93
+ { indexes: { 'by-text': ['text'] } } // name → field(s); query via `cero.get(ref, { text: '…' })`
94
+ )
95
+ ```
96
+
88
97
  ## Operators
89
98
 
90
99
  Every operator takes a `ref` (e.g. `me.profile`, `room.messages`) as the first arg.
@@ -110,19 +119,30 @@ await cero.set(room.messages, { id: 'abc', text: 'edited' }) // upsert by id
110
119
 
111
120
  ### `cero.get(ref, q?)`
112
121
 
113
- Read. Three shapes depending on `q`:
122
+ Read. The shape of `q` decides what comes back:
114
123
 
115
124
  ```js
116
125
  const { data } = await cero.get(me.profile) // single → the row (or null)
117
126
  const { data } = await cero.get(room.messages, 'abc') // by id → the row (or null)
127
+
128
+ // collection → paginated, with range filters
118
129
  const { data, total, size } = await cero.get(room.messages, {
119
- gt: 'm-2025', // filters: gt / gte / lt / lte
130
+ gt: 'm-2025', // range: gt / gte / lt / lte
120
131
  limit: 20,
121
132
  reverse: true
122
- }) // collection → paginated
133
+ })
134
+
135
+ // search → case-insensitive substring across string fields
136
+ const { data } = await cero.get(room.messages, { search: 'jo sm' })
137
+ // every space-separated term must match (AND); folds case + diacritics ('jose' ⇢ 'José').
138
+ // `fields` restricts which fields are searched (default: all string fields):
139
+ const { data } = await cero.get(room.guests, { search: 'jose', fields: ['name'] })
140
+
141
+ // exact field match → routed through a declared secondary index when the field has one
142
+ const { data } = await cero.get(room.messages, { text: 'alpha' })
123
143
  ```
124
144
 
125
- `total` is the unfiltered row count; `size` is what came back after `limit`.
145
+ `total` is the unfiltered row count; `size` is what came back after `limit`. `search` and exact-field filters compose with `limit` / `reverse`, and `cero.count(ref, q)` honors them too.
126
146
 
127
147
  ### `cero.del(ref, id)`
128
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cero-base/cero",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "description": "The ideal p2p API — everything is a handle, handles contain refs, refs contain rows.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -78,7 +78,7 @@
78
78
  "test": "ls test/*.test.js | xargs -P1 -n1 brittle-node"
79
79
  },
80
80
  "dependencies": {
81
- "@cero-base/core": "^0.8.9",
81
+ "@cero-base/core": "^0.8.10",
82
82
  "b4a": "^1.8.1",
83
83
  "bare-abort-controller": "^1.1.2",
84
84
  "bare-crypto": "^1.14.1",