reddb-cli 0.1.2-next.33 → 0.1.2-next.34
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 +77 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -251,6 +251,83 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
251
251
|
}
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
+
## Advanced Query Features
|
|
255
|
+
|
|
256
|
+
RedDB extends standard SQL with constructs designed for multi-model workflows. Below is a quick tour; see the full [query docs](docs/query/) for every option.
|
|
257
|
+
|
|
258
|
+
### Context Search
|
|
259
|
+
|
|
260
|
+
Find everything related to an entity across tables, graphs, vectors, documents, and key-values in one command:
|
|
261
|
+
|
|
262
|
+
```sql
|
|
263
|
+
SEARCH CONTEXT '081.232.036-08' FIELD cpf
|
|
264
|
+
SEARCH CONTEXT 'Alice' COLLECTION customers DEPTH 2 LIMIT 50
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Context search uses a three-tier strategy (field-value index, token index, then global scan), expands results through graph traversal, and groups hits by structure type.
|
|
268
|
+
|
|
269
|
+
### WITH Clauses
|
|
270
|
+
|
|
271
|
+
`WITH` clauses attach operational semantics directly to SQL statements:
|
|
272
|
+
|
|
273
|
+
```sql
|
|
274
|
+
-- Time-to-live on INSERT and UPDATE
|
|
275
|
+
INSERT INTO sessions (token) VALUES ('abc') WITH TTL 1 h
|
|
276
|
+
UPDATE sessions SET active = true WHERE id = 1 WITH TTL 2 h
|
|
277
|
+
|
|
278
|
+
-- Absolute expiration (epoch milliseconds)
|
|
279
|
+
INSERT INTO events (name) VALUES ('launch') WITH EXPIRES AT 1735689600000
|
|
280
|
+
|
|
281
|
+
-- Structured metadata
|
|
282
|
+
INSERT INTO logs (msg) VALUES ('test') WITH METADATA (source = 'api')
|
|
283
|
+
|
|
284
|
+
-- Context index declaration
|
|
285
|
+
CREATE TABLE customers (cpf TEXT, name TEXT) WITH CONTEXT INDEX ON (cpf)
|
|
286
|
+
|
|
287
|
+
-- Graph expansion on SELECT
|
|
288
|
+
SELECT * FROM customers WHERE cpf = '081' WITH EXPAND GRAPH DEPTH 2
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### GROUP BY / HAVING
|
|
292
|
+
|
|
293
|
+
Group results and filter groups after aggregation:
|
|
294
|
+
|
|
295
|
+
```sql
|
|
296
|
+
SELECT status FROM users GROUP BY status
|
|
297
|
+
SELECT dept, role FROM employees GROUP BY dept, role
|
|
298
|
+
SELECT dept FROM employees GROUP BY dept HAVING dept > 5 ORDER BY dept
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Multi-Language Queries
|
|
302
|
+
|
|
303
|
+
The query engine auto-detects the language, so you can mix paradigms against the same dataset:
|
|
304
|
+
|
|
305
|
+
| Language | Example |
|
|
306
|
+
|:---------|:--------|
|
|
307
|
+
| SQL | `SELECT * FROM hosts WHERE os = 'linux'` |
|
|
308
|
+
| Cypher | `MATCH (a:User)-[:FOLLOWS]->(b) RETURN b.name` |
|
|
309
|
+
| Gremlin | `g.V().hasLabel('person').out('FOLLOWS').values('name')` |
|
|
310
|
+
| SPARQL | `SELECT ?name WHERE { ?p :name ?name }` |
|
|
311
|
+
| Natural language | `show me all critical hosts` |
|
|
312
|
+
|
|
313
|
+
See [multi-mode queries](docs/query/multi-mode.md) for supported steps and patterns.
|
|
314
|
+
|
|
315
|
+
### Key-Value REST API
|
|
316
|
+
|
|
317
|
+
Every collection doubles as a KV store through dedicated REST endpoints:
|
|
318
|
+
|
|
319
|
+
```bash
|
|
320
|
+
# Read a key
|
|
321
|
+
curl http://127.0.0.1:8080/collections/config/kvs/theme
|
|
322
|
+
|
|
323
|
+
# Write a key
|
|
324
|
+
curl -X PUT http://127.0.0.1:8080/collections/config/kvs/theme \
|
|
325
|
+
-d '{"value":"dark"}'
|
|
326
|
+
|
|
327
|
+
# Delete a key
|
|
328
|
+
curl -X DELETE http://127.0.0.1:8080/collections/config/kvs/theme
|
|
329
|
+
```
|
|
330
|
+
|
|
254
331
|
## Documentation
|
|
255
332
|
|
|
256
333
|
- Docs home: [docs/README.md](docs/README.md)
|