You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arkiv uses a SQL-like query language to filter and retrieve entities based on their attributes. The query language supports standard comparison operators, logical operators, and parentheses for complex conditions.
183
+
184
+
#### Supported Operators
185
+
186
+
**Comparison Operators:**
187
+
-`=` - Equal to
188
+
-`!=` - Not equal to
189
+
-`>` - Greater than
190
+
-`>=` - Greater than or equal to
191
+
-`<` - Less than
192
+
-`<=` - Less than or equal to
193
+
194
+
**Logical Operators:**
195
+
-`AND` - Logical AND
196
+
-`OR` - Logical OR
197
+
-`NOT` - Logical NOT (can also use `!=`)
198
+
199
+
**Parentheses** can be used to group conditions and control evaluation order.
# Note that inn the examples below the call to query_entities is omitted
213
+
214
+
# Multiple conditions with AND
215
+
query ='type = "user" AND status = "active"'
216
+
217
+
# OR conditions with parentheses
218
+
query ='type = "user" AND (status = "active" OR status = "pending")'
219
+
220
+
# Comparison operators
221
+
query ='type = "user" AND age >= 18 AND age < 65'
222
+
223
+
# NOT conditions
224
+
query ='type = "user" AND status != "deleted"'
225
+
226
+
# Alternative NOT syntax
227
+
query ='type = "user" AND NOT (status = "deleted")'
228
+
229
+
# Complex nested conditions
230
+
query ='(type = "user" OR type = "admin") AND (age >= 18 AND age <= 65)'
231
+
232
+
# Multiple NOT conditions
233
+
query ='type = "user" AND status != "deleted" AND status != "banned"'
234
+
```
235
+
236
+
**Note:** String values in queries must be enclosed in double quotes (`"`). Numeric values do not require quotes.
237
+
238
+
### Watch Entity Events
239
+
240
+
Arkiv provides near real-time event monitoring for entity lifecycle changes. You can watch for entity creation, updates, extensions, deletions, and ownership changes using callback-based event filters.
241
+
242
+
#### Available Event Types
243
+
244
+
-**`watch_entity_created`** - Monitor when new entities are created
245
+
-**`watch_entity_updated`** - Monitor when entities are updated
246
+
-**`watch_entity_extended`** - Monitor when entity lifetimes are extended
247
+
-**`watch_entity_deleted`** - Monitor when entities are deleted
248
+
-**`watch_owner_changed`** - Monitor when entity ownership changes
# Filters are automatically stopped and uninstalled when exiting context
337
+
```
338
+
339
+
You can also manually clean up all active filters:
340
+
341
+
```python
342
+
client.arkiv.cleanup_filters()
343
+
```
344
+
345
+
**Note:** Event watching requires polling the node for new events. The SDK handles this automatically in the background.
346
+
182
347
## Arkiv Topics/Features
183
348
184
349
### BTL
@@ -217,24 +382,6 @@ updated_entity = replace(
217
382
client.arkiv.update_entity(updated_entity)
218
383
```
219
384
220
-
### Query DSL
221
-
222
-
To make querying entities as simple and natural as possible, rely on a suitable and existing query DSL. Since Arkiv currently uses a SQL database backend and is likely to support SQL databases in the future, the Arkiv query DSL is defined as a **subset of the SQL standard**.
223
-
224
-
**Rationale:**
225
-
- Leverages existing SQL knowledge - no new language to learn
226
-
- Well-defined semantics and broad tooling support
227
-
- Natural fit for relational data structures
228
-
- Enables familiar filtering, joining, and aggregation patterns
229
-
230
-
**Example:**
231
-
```python
232
-
# Query entities using SQL-like syntax
233
-
results = client.arkiv.query_entities(
234
-
"SELECT key, payload WHERE attributes.type = 'user' AND attributes.age > 18 ORDER BY attributes.name"
235
-
)
236
-
```
237
-
238
385
### Sorting
239
386
240
387
Querying entities should support sorting results by one or more fields.
0 commit comments