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
# Modify payload and extend expiration by 100 blocks
137
+
updated_entity = replace(
138
+
entity,
139
+
payload=b"new data",
140
+
expires_at_block=entity.expires_at_block +100
141
+
)
142
+
143
+
# Update entity
144
+
client.arkiv.update_entity(updated_entity)
94
145
```
95
146
96
-
### Arkiv Module Extension
147
+
### Query DSL
148
+
149
+
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**.
150
+
151
+
**Rationale:**
152
+
- Leverages existing SQL knowledge - no new language to learn
153
+
- Well-defined semantics and broad tooling support
154
+
- Natural fit for relational data structures
155
+
- Enables familiar filtering, joining, and aggregation patterns
156
+
157
+
**Example:**
97
158
```python
98
-
from arkiv import Arkiv
99
-
from arkiv.account import NamedAccount
159
+
# Query entities using SQL-like syntax
160
+
results = client.arkiv.query(
161
+
"SELECT entity_key, payload WHERE annotations.type = 'user' AND annotations.age > 18 ORDER BY annotations.name"
page = client.arkiv.query("SELECT * FROM entities", max_page_size=100)
178
+
179
+
# Fetch next page using cursor
180
+
next_page = client.arkiv.query("SELECT * FROM entities", cursor=page.next, max_page_size=100)
181
+
```
182
+
183
+
### Sorting
184
+
185
+
Querying entities should support sorting results by one or more fields.
186
+
187
+
**Requirements:**
188
+
- Sort by annotations (string and numeric)
189
+
- Sort by metadata (owner, expires_at_block)
190
+
- Support ascending and descending order
191
+
- Multi-field sorting with priority
192
+
193
+
**Example:**
194
+
```python
195
+
# SQL-style sorting
196
+
results = client.arkiv.query(
197
+
"SELECT * FROM entities ORDER BY annotations.priority DESC, annotations.name ASC"
108
198
)
199
+
```
200
+
201
+
### Projections
202
+
203
+
The transfer of large entities or many entities consumes considerable bandwidth. Which information per entity is most valuable is use-case specific and should be specified by the application.
204
+
205
+
**Let users decide which parts of an entity to return:**
206
+
-**Payload** - Binary data (can be large)
207
+
-**Annotations** - Key-value metadata
208
+
-**Metadata** - Owner, expiration, timestamps
209
+
210
+
**Current implementation:**
211
+
The SDK already supports projections via the `fields` parameter using bitmask flags:
212
+
```python
213
+
from arkiv.types importPAYLOAD, ANNOTATIONS, METADATA
0 commit comments