rushdb 0.3.0__tar.gz → 1.2.0__tar.gz
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.
- {rushdb-0.3.0 → rushdb-1.2.0}/PKG-INFO +161 -183
- {rushdb-0.3.0 → rushdb-1.2.0}/README.md +160 -182
- {rushdb-0.3.0 → rushdb-1.2.0}/pyproject.toml +1 -1
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/labels.py +3 -3
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/properties.py +17 -14
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/records.py +20 -28
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/relationships.py +6 -3
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/transactions.py +3 -7
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/client.py +2 -2
- {rushdb-0.3.0 → rushdb-1.2.0}/LICENSE +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/__init__.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/__init__.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/api/base.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/common.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/__init__.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/property.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/record.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/relationship.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/search_query.py +0 -0
- {rushdb-0.3.0 → rushdb-1.2.0}/src/rushdb/models/transaction.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rushdb
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.2.0
|
|
4
4
|
Summary: RushDB Python SDK
|
|
5
5
|
Home-page: https://github.com/rushdb/rushdb-python
|
|
6
6
|
License: Apache-2.0
|
|
@@ -26,219 +26,123 @@ Description-Content-Type: text/markdown
|
|
|
26
26
|

|
|
27
27
|
|
|
28
28
|
# RushDB Python SDK
|
|
29
|
-

|
|
30
29
|
|
|
30
|
+

|
|
31
31
|

|
|
32
|
-
|
|
33
32
|

|
|
34
33
|
|
|
35
34
|
RushDB is an instant database for modern apps and DS/ML ops built on top of Neo4j.
|
|
35
|
+
It automates data normalization, manages relationships, and infers data types.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
[📖 Documentation](https://docs.rushdb.com/python-sdk/introduction) • [🌐 Website](https://rushdb.com) • [☁️ Cloud Platform](https://app.rushdb.com)
|
|
38
38
|
|
|
39
|
-
[🌐 Homepage](https://rushdb.com) — [📢 Blog](https://rushdb.com/blog) — [☁️ Platform ](https://app.rushdb.com) — [📚 Docs](https://docs.rushdb.com/python-sdk/records-api) — [🧑💻 Examples](https://github.com/rush-db/examples)
|
|
40
39
|
</div>
|
|
41
40
|
|
|
42
|
-
---
|
|
43
|
-
|
|
44
41
|
## Installation
|
|
45
42
|
|
|
46
|
-
Install the RushDB Python SDK via pip:
|
|
47
|
-
|
|
48
|
-
|
|
49
43
|
```sh
|
|
50
44
|
pip install rushdb
|
|
51
45
|
```
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## Usage
|
|
56
|
-
|
|
57
|
-
### **1. Setup SDK**
|
|
47
|
+
## Quick Start
|
|
58
48
|
|
|
59
49
|
```python
|
|
60
50
|
from rushdb import RushDB
|
|
61
51
|
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
# Initialize the client
|
|
53
|
+
db = RushDB("YOUR_API_TOKEN")
|
|
64
54
|
|
|
65
|
-
|
|
55
|
+
# Create a record
|
|
56
|
+
user = db.records.create(
|
|
57
|
+
label="USER",
|
|
58
|
+
data={
|
|
59
|
+
"name": "John Doe",
|
|
60
|
+
"email": "john@example.com",
|
|
61
|
+
"age": 30
|
|
62
|
+
}
|
|
63
|
+
)
|
|
66
64
|
|
|
67
|
-
|
|
65
|
+
# Find records
|
|
66
|
+
results = db.records.find({
|
|
67
|
+
"where": {
|
|
68
|
+
"age": {"$gte": 18},
|
|
69
|
+
"name": {"$startsWith": "J"}
|
|
70
|
+
},
|
|
71
|
+
"limit": 10
|
|
72
|
+
})
|
|
68
73
|
|
|
74
|
+
# Create relationships
|
|
75
|
+
company = db.records.create(
|
|
76
|
+
label="COMPANY",
|
|
77
|
+
data={"name": "Acme Inc."}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Attach records with a relationship
|
|
81
|
+
user.attach(
|
|
82
|
+
target=company,
|
|
83
|
+
options={"type": "WORKS_AT", "direction": "out"}
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Pushing Nested JSON
|
|
88
|
+
|
|
89
|
+
RushDB automatically normalizes nested objects into a graph structure:
|
|
69
90
|
|
|
70
91
|
```python
|
|
71
|
-
|
|
92
|
+
# Push nested JSON with automatic relationship creation
|
|
93
|
+
db.records.create_many("COMPANY", {
|
|
72
94
|
"name": "Google LLC",
|
|
73
|
-
"address": "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
|
|
74
|
-
"foundedAt": "1998-09-04T00:00:00.000Z",
|
|
75
95
|
"rating": 4.9,
|
|
76
96
|
"DEPARTMENT": [{
|
|
77
97
|
"name": "Research & Development",
|
|
78
|
-
"description": "Innovating and creating advanced technologies for AI, cloud computing, and consumer devices.",
|
|
79
98
|
"PROJECT": [{
|
|
80
99
|
"name": "Bard AI",
|
|
81
|
-
"description": "A state-of-the-art generative AI model for natural language understanding and creation.",
|
|
82
|
-
"active": True,
|
|
83
|
-
"budget": 1200000000,
|
|
84
100
|
"EMPLOYEE": [{
|
|
85
101
|
"name": "Jeff Dean",
|
|
86
|
-
"position": "Head of AI Research"
|
|
87
|
-
"email": "jeff@google.com",
|
|
88
|
-
"dob": "1968-07-16T00:00:00.000Z",
|
|
89
|
-
"salary": 3000000
|
|
102
|
+
"position": "Head of AI Research"
|
|
90
103
|
}]
|
|
91
104
|
}]
|
|
92
105
|
}]
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
db.records.create_many("COMPANY", company_data)
|
|
106
|
+
})
|
|
96
107
|
```
|
|
97
108
|
|
|
98
|
-
|
|
109
|
+
## Complete Documentation
|
|
99
110
|
|
|
100
|
-
|
|
101
|
-
(Record:COMPANY)
|
|
102
|
-
-[r0:RUSHDB_DEFAULT_RELATION]->
|
|
103
|
-
(Record:DEPARTMENT)
|
|
104
|
-
-[r1:RUSHDB_DEFAULT_RELATION]->
|
|
105
|
-
(Record:PROJECT)
|
|
106
|
-
-[r2:RUSHDB_DEFAULT_RELATION]->
|
|
107
|
-
(Record:EMPLOYEE)
|
|
108
|
-
```
|
|
111
|
+
For comprehensive documentation, tutorials, and examples, please visit:
|
|
109
112
|
|
|
110
|
-
|
|
113
|
+
**[docs.rushdb.com/python-sdk](https://docs.rushdb.com/python-sdk/introduction)**
|
|
111
114
|
|
|
112
|
-
|
|
115
|
+
Documentation includes:
|
|
113
116
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"DEPARTMENT": {
|
|
121
|
-
"COMPANY": {
|
|
122
|
-
"rating": {"$gte": 4}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
117
|
+
- Complete Records API reference
|
|
118
|
+
- Relationship management
|
|
119
|
+
- Complex query examples
|
|
120
|
+
- Transaction usage
|
|
121
|
+
- Vector search capabilities
|
|
122
|
+
- Data import tools
|
|
128
123
|
|
|
129
|
-
|
|
124
|
+
## Support
|
|
130
125
|
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
- [GitHub Issues](https://github.com/rush-db/rushdb-python/issues) - Bug reports and feature requests
|
|
127
|
+
- [Discord Community](https://discord.gg/rushdb) - Get help from the community
|
|
128
|
+
- [Email Support](mailto:support@rushdb.com) - Direct support from the RushDB team
|
|
133
129
|
|
|
134
130
|
---
|
|
135
131
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
## Methods
|
|
144
|
-
|
|
145
|
-
### create()
|
|
146
|
-
|
|
147
|
-
Creates a new record in RushDB.
|
|
148
|
-
|
|
149
|
-
**Signature:**
|
|
150
|
-
```python
|
|
151
|
-
def create(
|
|
152
|
-
self,
|
|
153
|
-
label: str,
|
|
154
|
-
data: Dict[str, Any],
|
|
155
|
-
options: Optional[Dict[str, bool]] = None,
|
|
156
|
-
transaction: Optional[Transaction] = None
|
|
157
|
-
) -> Record
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
**Arguments:**
|
|
161
|
-
- `label` (str): Label for the record
|
|
162
|
-
- `data` (Dict[str, Any]): Record data
|
|
163
|
-
- `options` (Optional[Dict[str, bool]]): Optional parsing and response options
|
|
164
|
-
- `returnResult` (bool): Whether to return the created record
|
|
165
|
-
- `suggestTypes` (bool): Whether to suggest property types
|
|
166
|
-
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
167
|
-
|
|
168
|
-
**Returns:**
|
|
169
|
-
- `Record`: Created record object
|
|
170
|
-
|
|
171
|
-
**Example:**
|
|
172
|
-
```python
|
|
173
|
-
# Create a new company record
|
|
174
|
-
data = {
|
|
175
|
-
"name": "Google LLC",
|
|
176
|
-
"address": "1600 Amphitheatre Parkway",
|
|
177
|
-
"foundedAt": "1998-09-04T00:00:00.000Z",
|
|
178
|
-
"rating": 4.9
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
record = db.records.create(
|
|
182
|
-
label="COMPANY",
|
|
183
|
-
data=data,
|
|
184
|
-
options={"returnResult": True, "suggestTypes": True}
|
|
185
|
-
)
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### create_many()
|
|
189
|
-
|
|
190
|
-
Creates multiple records in a single operation.
|
|
191
|
-
|
|
192
|
-
**Signature:**
|
|
193
|
-
```python
|
|
194
|
-
def create_many(
|
|
195
|
-
self,
|
|
196
|
-
label: str,
|
|
197
|
-
data: Union[Dict[str, Any], List[Dict[str, Any]]],
|
|
198
|
-
options: Optional[Dict[str, bool]] = None,
|
|
199
|
-
transaction: Optional[Transaction] = None
|
|
200
|
-
) -> List[Record]
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
**Arguments:**
|
|
204
|
-
- `label` (str): Label for all records
|
|
205
|
-
- `data` (Union[Dict[str, Any], List[Dict[str, Any]]]): List or Dict of record data
|
|
206
|
-
- `options` (Optional[Dict[str, bool]]): Optional parsing and response options
|
|
207
|
-
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
208
|
-
|
|
209
|
-
**Returns:**
|
|
210
|
-
- `List[Record]`: List of created record objects
|
|
211
|
-
|
|
212
|
-
**Example:**
|
|
213
|
-
```python
|
|
214
|
-
# Create multiple company records
|
|
215
|
-
data = [
|
|
216
|
-
{
|
|
217
|
-
"name": "Apple Inc",
|
|
218
|
-
"address": "One Apple Park Way",
|
|
219
|
-
"foundedAt": "1976-04-01T00:00:00.000Z",
|
|
220
|
-
"rating": 4.8
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
"name": "Microsoft Corporation",
|
|
224
|
-
"address": "One Microsoft Way",
|
|
225
|
-
"foundedAt": "1975-04-04T00:00:00.000Z",
|
|
226
|
-
"rating": 4.7
|
|
227
|
-
}
|
|
228
|
-
]
|
|
229
|
-
|
|
230
|
-
records = db.records.create_many(
|
|
231
|
-
label="COMPANY",
|
|
232
|
-
data=data,
|
|
233
|
-
options={"returnResult": True, "suggestTypes": True}
|
|
234
|
-
)
|
|
235
|
-
```
|
|
132
|
+
<div align="center">
|
|
133
|
+
<p>
|
|
134
|
+
<a href="https://docs.rushdb.com/python-sdk/introduction">
|
|
135
|
+
<img src="https://img.shields.io/badge/Full_Documentation-docs.rushdb.com-6D28D9?style=for-the-badge" alt="View Documentation" />
|
|
136
|
+
</a>
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
236
139
|
|
|
237
140
|
### set()
|
|
238
141
|
|
|
239
142
|
Updates a record by ID, replacing all data.
|
|
240
143
|
|
|
241
144
|
**Signature:**
|
|
145
|
+
|
|
242
146
|
```python
|
|
243
147
|
def set(
|
|
244
148
|
self,
|
|
@@ -249,14 +153,17 @@ def set(
|
|
|
249
153
|
```
|
|
250
154
|
|
|
251
155
|
**Arguments:**
|
|
156
|
+
|
|
252
157
|
- `record_id` (str): ID of the record to update
|
|
253
158
|
- `data` (Dict[str, Any]): New record data
|
|
254
159
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
255
160
|
|
|
256
161
|
**Returns:**
|
|
162
|
+
|
|
257
163
|
- `Dict[str, str]`: Response data
|
|
258
164
|
|
|
259
165
|
**Example:**
|
|
166
|
+
|
|
260
167
|
```python
|
|
261
168
|
# Update entire record data
|
|
262
169
|
new_data = {
|
|
@@ -275,6 +182,7 @@ response = db.records.set(
|
|
|
275
182
|
Updates specific fields of a record by ID.
|
|
276
183
|
|
|
277
184
|
**Signature:**
|
|
185
|
+
|
|
278
186
|
```python
|
|
279
187
|
def update(
|
|
280
188
|
self,
|
|
@@ -285,14 +193,17 @@ def update(
|
|
|
285
193
|
```
|
|
286
194
|
|
|
287
195
|
**Arguments:**
|
|
196
|
+
|
|
288
197
|
- `record_id` (str): ID of the record to update
|
|
289
198
|
- `data` (Dict[str, Any]): Partial record data to update
|
|
290
199
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
291
200
|
|
|
292
201
|
**Returns:**
|
|
202
|
+
|
|
293
203
|
- `Dict[str, str]`: Response data
|
|
294
204
|
|
|
295
205
|
**Example:**
|
|
206
|
+
|
|
296
207
|
```python
|
|
297
208
|
# Update specific fields
|
|
298
209
|
updates = {
|
|
@@ -311,24 +222,28 @@ response = db.records.update(
|
|
|
311
222
|
Searches for records matching specified criteria.
|
|
312
223
|
|
|
313
224
|
**Signature:**
|
|
225
|
+
|
|
314
226
|
```python
|
|
315
227
|
def find(
|
|
316
228
|
self,
|
|
317
|
-
|
|
229
|
+
search_query: Optional[SearchQuery] = None,
|
|
318
230
|
record_id: Optional[str] = None,
|
|
319
231
|
transaction: Optional[Transaction] = None
|
|
320
232
|
) -> List[Record]
|
|
321
233
|
```
|
|
322
234
|
|
|
323
235
|
**Arguments:**
|
|
236
|
+
|
|
324
237
|
- `query` (Optional[SearchQuery]): Search query parameters
|
|
325
238
|
- `record_id` (Optional[str]): Optional record ID to search from
|
|
326
239
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
327
240
|
|
|
328
241
|
**Returns:**
|
|
242
|
+
|
|
329
243
|
- `List[Record]`: List of matching records
|
|
330
244
|
|
|
331
245
|
**Example:**
|
|
246
|
+
|
|
332
247
|
```python
|
|
333
248
|
# Search for records with complex criteria
|
|
334
249
|
query = {
|
|
@@ -351,6 +266,7 @@ records = db.records.find(query=query)
|
|
|
351
266
|
Deletes records matching a query.
|
|
352
267
|
|
|
353
268
|
**Signature:**
|
|
269
|
+
|
|
354
270
|
```python
|
|
355
271
|
def delete(
|
|
356
272
|
self,
|
|
@@ -360,13 +276,16 @@ def delete(
|
|
|
360
276
|
```
|
|
361
277
|
|
|
362
278
|
**Arguments:**
|
|
279
|
+
|
|
363
280
|
- `query` (SearchQuery): Query to match records for deletion
|
|
364
281
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
365
282
|
|
|
366
283
|
**Returns:**
|
|
284
|
+
|
|
367
285
|
- `Dict[str, str]`: Response data
|
|
368
286
|
|
|
369
287
|
**Example:**
|
|
288
|
+
|
|
370
289
|
```python
|
|
371
290
|
# Delete records matching criteria
|
|
372
291
|
query = {
|
|
@@ -384,6 +303,7 @@ response = db.records.delete(query)
|
|
|
384
303
|
Deletes one or more records by ID.
|
|
385
304
|
|
|
386
305
|
**Signature:**
|
|
306
|
+
|
|
387
307
|
```python
|
|
388
308
|
def delete_by_id(
|
|
389
309
|
self,
|
|
@@ -393,13 +313,16 @@ def delete_by_id(
|
|
|
393
313
|
```
|
|
394
314
|
|
|
395
315
|
**Arguments:**
|
|
316
|
+
|
|
396
317
|
- `id_or_ids` (Union[str, List[str]]): Single ID or list of IDs to delete
|
|
397
318
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
398
319
|
|
|
399
320
|
**Returns:**
|
|
321
|
+
|
|
400
322
|
- `Dict[str, str]`: Response data
|
|
401
323
|
|
|
402
324
|
**Example:**
|
|
325
|
+
|
|
403
326
|
```python
|
|
404
327
|
# Delete single record
|
|
405
328
|
response = db.records.delete_by_id("record-123")
|
|
@@ -417,6 +340,7 @@ response = db.records.delete_by_id([
|
|
|
417
340
|
Creates relationships between records.
|
|
418
341
|
|
|
419
342
|
**Signature:**
|
|
343
|
+
|
|
420
344
|
```python
|
|
421
345
|
def attach(
|
|
422
346
|
self,
|
|
@@ -428,6 +352,7 @@ def attach(
|
|
|
428
352
|
```
|
|
429
353
|
|
|
430
354
|
**Arguments:**
|
|
355
|
+
|
|
431
356
|
- `source` (Union[str, Dict[str, Any]]): Source record ID or data
|
|
432
357
|
- `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
|
|
433
358
|
- `options` (Optional[RelationshipOptions]): Relationship options
|
|
@@ -436,9 +361,11 @@ def attach(
|
|
|
436
361
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
437
362
|
|
|
438
363
|
**Returns:**
|
|
364
|
+
|
|
439
365
|
- `Dict[str, str]`: Response data
|
|
440
366
|
|
|
441
367
|
**Example:**
|
|
368
|
+
|
|
442
369
|
```python
|
|
443
370
|
# Create relationship between records
|
|
444
371
|
options = RelationshipOptions(
|
|
@@ -458,6 +385,7 @@ response = db.records.attach(
|
|
|
458
385
|
Removes relationships between records.
|
|
459
386
|
|
|
460
387
|
**Signature:**
|
|
388
|
+
|
|
461
389
|
```python
|
|
462
390
|
def detach(
|
|
463
391
|
self,
|
|
@@ -469,6 +397,7 @@ def detach(
|
|
|
469
397
|
```
|
|
470
398
|
|
|
471
399
|
**Arguments:**
|
|
400
|
+
|
|
472
401
|
- `source` (Union[str, Dict[str, Any]]): Source record ID or data
|
|
473
402
|
- `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
|
|
474
403
|
- `options` (Optional[RelationshipDetachOptions]): Detach options
|
|
@@ -477,9 +406,11 @@ def detach(
|
|
|
477
406
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
478
407
|
|
|
479
408
|
**Returns:**
|
|
409
|
+
|
|
480
410
|
- `Dict[str, str]`: Response data
|
|
481
411
|
|
|
482
412
|
**Example:**
|
|
413
|
+
|
|
483
414
|
```python
|
|
484
415
|
# Remove relationships between records
|
|
485
416
|
options = RelationshipDetachOptions(
|
|
@@ -499,6 +430,7 @@ response = db.records.detach(
|
|
|
499
430
|
Imports records from CSV data.
|
|
500
431
|
|
|
501
432
|
**Signature:**
|
|
433
|
+
|
|
502
434
|
```python
|
|
503
435
|
def import_csv(
|
|
504
436
|
self,
|
|
@@ -510,15 +442,18 @@ def import_csv(
|
|
|
510
442
|
```
|
|
511
443
|
|
|
512
444
|
**Arguments:**
|
|
445
|
+
|
|
513
446
|
- `label` (str): Label for imported records
|
|
514
447
|
- `csv_data` (Union[str, bytes]): CSV data to import
|
|
515
448
|
- `options` (Optional[Dict[str, bool]]): Import options
|
|
516
449
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
517
450
|
|
|
518
451
|
**Returns:**
|
|
452
|
+
|
|
519
453
|
- `List[Dict[str, Any]]`: Imported records data
|
|
520
454
|
|
|
521
455
|
**Example:**
|
|
456
|
+
|
|
522
457
|
```python
|
|
523
458
|
# Import records from CSV
|
|
524
459
|
csv_data = """name,age,department,role
|
|
@@ -555,6 +490,7 @@ Gets the record's unique identifier.
|
|
|
555
490
|
**Type:** `str`
|
|
556
491
|
|
|
557
492
|
**Example:**
|
|
493
|
+
|
|
558
494
|
```python
|
|
559
495
|
record = db.records.create("USER", {"name": "John"})
|
|
560
496
|
print(record.id) # e.g., "1234abcd-5678-..."
|
|
@@ -567,6 +503,7 @@ Gets the record's property types.
|
|
|
567
503
|
**Type:** `str`
|
|
568
504
|
|
|
569
505
|
**Example:**
|
|
506
|
+
|
|
570
507
|
```python
|
|
571
508
|
record = db.records.create("USER", {"name": "John", "age": 25})
|
|
572
509
|
print(record.proptypes) # Returns property type definitions
|
|
@@ -579,6 +516,7 @@ Gets the record's label.
|
|
|
579
516
|
**Type:** `str`
|
|
580
517
|
|
|
581
518
|
**Example:**
|
|
519
|
+
|
|
582
520
|
```python
|
|
583
521
|
record = db.records.create("USER", {"name": "John"})
|
|
584
522
|
print(record.label) # "USER"
|
|
@@ -591,6 +529,7 @@ Gets the record's creation timestamp from its ID.
|
|
|
591
529
|
**Type:** `int`
|
|
592
530
|
|
|
593
531
|
**Example:**
|
|
532
|
+
|
|
594
533
|
```python
|
|
595
534
|
record = db.records.create("USER", {"name": "John"})
|
|
596
535
|
print(record.timestamp) # Unix timestamp in milliseconds
|
|
@@ -603,6 +542,7 @@ Gets the record's creation date.
|
|
|
603
542
|
**Type:** `datetime`
|
|
604
543
|
|
|
605
544
|
**Example:**
|
|
545
|
+
|
|
606
546
|
```python
|
|
607
547
|
record = db.records.create("USER", {"name": "John"})
|
|
608
548
|
print(record.date) # datetime object
|
|
@@ -615,6 +555,7 @@ print(record.date) # datetime object
|
|
|
615
555
|
Updates all data for the record.
|
|
616
556
|
|
|
617
557
|
**Signature:**
|
|
558
|
+
|
|
618
559
|
```python
|
|
619
560
|
def set(
|
|
620
561
|
self,
|
|
@@ -624,13 +565,16 @@ def set(
|
|
|
624
565
|
```
|
|
625
566
|
|
|
626
567
|
**Arguments:**
|
|
568
|
+
|
|
627
569
|
- `data` (Dict[str, Any]): New record data
|
|
628
570
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
629
571
|
|
|
630
572
|
**Returns:**
|
|
573
|
+
|
|
631
574
|
- `Dict[str, str]`: Response data
|
|
632
575
|
|
|
633
576
|
**Example:**
|
|
577
|
+
|
|
634
578
|
```python
|
|
635
579
|
record = db.records.create("USER", {"name": "John"})
|
|
636
580
|
response = record.set({
|
|
@@ -645,6 +589,7 @@ response = record.set({
|
|
|
645
589
|
Updates specific fields of the record.
|
|
646
590
|
|
|
647
591
|
**Signature:**
|
|
592
|
+
|
|
648
593
|
```python
|
|
649
594
|
def update(
|
|
650
595
|
self,
|
|
@@ -654,13 +599,16 @@ def update(
|
|
|
654
599
|
```
|
|
655
600
|
|
|
656
601
|
**Arguments:**
|
|
602
|
+
|
|
657
603
|
- `data` (Dict[str, Any]): Partial record data to update
|
|
658
604
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
659
605
|
|
|
660
606
|
**Returns:**
|
|
607
|
+
|
|
661
608
|
- `Dict[str, str]`: Response data
|
|
662
609
|
|
|
663
610
|
**Example:**
|
|
611
|
+
|
|
664
612
|
```python
|
|
665
613
|
record = db.records.create("USER", {
|
|
666
614
|
"name": "John",
|
|
@@ -676,6 +624,7 @@ response = record.update({
|
|
|
676
624
|
Creates relationships with other records.
|
|
677
625
|
|
|
678
626
|
**Signature:**
|
|
627
|
+
|
|
679
628
|
```python
|
|
680
629
|
def attach(
|
|
681
630
|
self,
|
|
@@ -686,6 +635,7 @@ def attach(
|
|
|
686
635
|
```
|
|
687
636
|
|
|
688
637
|
**Arguments:**
|
|
638
|
+
|
|
689
639
|
- `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
|
|
690
640
|
- `options` (Optional[RelationshipOptions]): Relationship options
|
|
691
641
|
- `direction` (Optional[Literal["in", "out"]]): Relationship direction
|
|
@@ -693,9 +643,11 @@ def attach(
|
|
|
693
643
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
694
644
|
|
|
695
645
|
**Returns:**
|
|
646
|
+
|
|
696
647
|
- `Dict[str, str]`: Response data
|
|
697
648
|
|
|
698
649
|
**Example:**
|
|
650
|
+
|
|
699
651
|
```python
|
|
700
652
|
# Create two records
|
|
701
653
|
user = db.records.create("USER", {"name": "John"})
|
|
@@ -716,6 +668,7 @@ response = user.attach(
|
|
|
716
668
|
Removes relationships with other records.
|
|
717
669
|
|
|
718
670
|
**Signature:**
|
|
671
|
+
|
|
719
672
|
```python
|
|
720
673
|
def detach(
|
|
721
674
|
self,
|
|
@@ -726,6 +679,7 @@ def detach(
|
|
|
726
679
|
```
|
|
727
680
|
|
|
728
681
|
**Arguments:**
|
|
682
|
+
|
|
729
683
|
- `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
|
|
730
684
|
- `options` (Optional[RelationshipDetachOptions]): Detach options
|
|
731
685
|
- `direction` (Optional[Literal["in", "out"]]): Relationship direction
|
|
@@ -733,9 +687,11 @@ def detach(
|
|
|
733
687
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
734
688
|
|
|
735
689
|
**Returns:**
|
|
690
|
+
|
|
736
691
|
- `Dict[str, str]`: Response data
|
|
737
692
|
|
|
738
693
|
**Example:**
|
|
694
|
+
|
|
739
695
|
```python
|
|
740
696
|
# Detach user from group
|
|
741
697
|
response = user.detach(
|
|
@@ -752,6 +708,7 @@ response = user.detach(
|
|
|
752
708
|
Deletes the record.
|
|
753
709
|
|
|
754
710
|
**Signature:**
|
|
711
|
+
|
|
755
712
|
```python
|
|
756
713
|
def delete(
|
|
757
714
|
self,
|
|
@@ -760,12 +717,15 @@ def delete(
|
|
|
760
717
|
```
|
|
761
718
|
|
|
762
719
|
**Arguments:**
|
|
720
|
+
|
|
763
721
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
764
722
|
|
|
765
723
|
**Returns:**
|
|
724
|
+
|
|
766
725
|
- `Dict[str, str]`: Response data
|
|
767
726
|
|
|
768
727
|
**Example:**
|
|
728
|
+
|
|
769
729
|
```python
|
|
770
730
|
user = db.records.create("USER", {"name": "John"})
|
|
771
731
|
response = user.delete()
|
|
@@ -846,26 +806,26 @@ with db.transactions.begin() as transaction:
|
|
|
846
806
|
{"name": "John Doe"},
|
|
847
807
|
transaction=transaction
|
|
848
808
|
)
|
|
849
|
-
|
|
809
|
+
|
|
850
810
|
# Update user
|
|
851
811
|
user.update(
|
|
852
812
|
{"status": "active"},
|
|
853
813
|
transaction=transaction
|
|
854
814
|
)
|
|
855
|
-
|
|
815
|
+
|
|
856
816
|
# Create and attach department
|
|
857
817
|
dept = db.records.create(
|
|
858
818
|
"DEPARTMENT",
|
|
859
819
|
{"name": "Engineering"},
|
|
860
820
|
transaction=transaction
|
|
861
821
|
)
|
|
862
|
-
|
|
822
|
+
|
|
863
823
|
user.attach(
|
|
864
824
|
target=dept,
|
|
865
825
|
options=RelationshipOptions(type="BELONGS_TO"),
|
|
866
826
|
transaction=transaction
|
|
867
827
|
)
|
|
868
|
-
|
|
828
|
+
|
|
869
829
|
# Transaction will automatically commit if no errors occur
|
|
870
830
|
# If an error occurs, it will automatically rollback
|
|
871
831
|
```
|
|
@@ -889,25 +849,29 @@ class PropertiesAPI(BaseAPI):
|
|
|
889
849
|
Retrieves a list of properties based on optional search criteria.
|
|
890
850
|
|
|
891
851
|
**Signature:**
|
|
852
|
+
|
|
892
853
|
```python
|
|
893
854
|
def find(
|
|
894
855
|
self,
|
|
895
|
-
|
|
856
|
+
search_query: Optional[SearchQuery] = None,
|
|
896
857
|
transaction: Optional[Transaction] = None
|
|
897
858
|
) -> List[Property]
|
|
898
859
|
```
|
|
899
860
|
|
|
900
861
|
**Arguments:**
|
|
862
|
+
|
|
901
863
|
- `query` (Optional[SearchQuery]): Search query parameters for filtering properties
|
|
902
864
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
903
865
|
|
|
904
866
|
**Returns:**
|
|
867
|
+
|
|
905
868
|
- `List[Property]`: List of properties matching the search criteria
|
|
906
869
|
|
|
907
870
|
**Example:**
|
|
871
|
+
|
|
908
872
|
```python
|
|
909
873
|
# Find all properties
|
|
910
|
-
properties =
|
|
874
|
+
properties = db.properties.find()
|
|
911
875
|
|
|
912
876
|
# Find properties with specific criteria
|
|
913
877
|
query = {
|
|
@@ -917,7 +881,7 @@ query = {
|
|
|
917
881
|
},
|
|
918
882
|
"limit": 10 # Limit to 10 results
|
|
919
883
|
}
|
|
920
|
-
filtered_properties =
|
|
884
|
+
filtered_properties = db.properties.find(query)
|
|
921
885
|
```
|
|
922
886
|
|
|
923
887
|
### find_by_id()
|
|
@@ -925,6 +889,7 @@ filtered_properties = client.properties.find(query)
|
|
|
925
889
|
Retrieves a specific property by its ID.
|
|
926
890
|
|
|
927
891
|
**Signature:**
|
|
892
|
+
|
|
928
893
|
```python
|
|
929
894
|
def find_by_id(
|
|
930
895
|
self,
|
|
@@ -934,16 +899,19 @@ def find_by_id(
|
|
|
934
899
|
```
|
|
935
900
|
|
|
936
901
|
**Arguments:**
|
|
902
|
+
|
|
937
903
|
- `property_id` (str): Unique identifier of the property
|
|
938
904
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
939
905
|
|
|
940
906
|
**Returns:**
|
|
907
|
+
|
|
941
908
|
- `Property`: Property details
|
|
942
909
|
|
|
943
910
|
**Example:**
|
|
911
|
+
|
|
944
912
|
```python
|
|
945
913
|
# Retrieve a specific property by ID
|
|
946
|
-
property_details =
|
|
914
|
+
property_details = db.properties.find_by_id("prop_123456")
|
|
947
915
|
```
|
|
948
916
|
|
|
949
917
|
### delete()
|
|
@@ -951,6 +919,7 @@ property_details = client.properties.find_by_id("prop_123456")
|
|
|
951
919
|
Deletes a property by its ID.
|
|
952
920
|
|
|
953
921
|
**Signature:**
|
|
922
|
+
|
|
954
923
|
```python
|
|
955
924
|
def delete(
|
|
956
925
|
self,
|
|
@@ -960,16 +929,19 @@ def delete(
|
|
|
960
929
|
```
|
|
961
930
|
|
|
962
931
|
**Arguments:**
|
|
932
|
+
|
|
963
933
|
- `property_id` (str): Unique identifier of the property to delete
|
|
964
934
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
965
935
|
|
|
966
936
|
**Returns:**
|
|
937
|
+
|
|
967
938
|
- `None`
|
|
968
939
|
|
|
969
940
|
**Example:**
|
|
941
|
+
|
|
970
942
|
```python
|
|
971
943
|
# Delete a property
|
|
972
|
-
|
|
944
|
+
db.properties.delete("prop_123456")
|
|
973
945
|
```
|
|
974
946
|
|
|
975
947
|
### values()
|
|
@@ -977,6 +949,7 @@ client.properties.delete("prop_123456")
|
|
|
977
949
|
Retrieves values for a specific property with optional sorting and pagination.
|
|
978
950
|
|
|
979
951
|
**Signature:**
|
|
952
|
+
|
|
980
953
|
```python
|
|
981
954
|
def values(
|
|
982
955
|
self,
|
|
@@ -989,6 +962,7 @@ def values(
|
|
|
989
962
|
```
|
|
990
963
|
|
|
991
964
|
**Arguments:**
|
|
965
|
+
|
|
992
966
|
- `property_id` (str): Unique identifier of the property
|
|
993
967
|
- `sort` (Optional[Literal["asc", "desc"]]): Sort order of values
|
|
994
968
|
- `skip` (Optional[int]): Number of values to skip (for pagination)
|
|
@@ -996,12 +970,14 @@ def values(
|
|
|
996
970
|
- `transaction` (Optional[Transaction]): Optional transaction object
|
|
997
971
|
|
|
998
972
|
**Returns:**
|
|
973
|
+
|
|
999
974
|
- `PropertyValuesData`: Property values data, including optional min/max and list of values
|
|
1000
975
|
|
|
1001
976
|
**Example:**
|
|
977
|
+
|
|
1002
978
|
```python
|
|
1003
979
|
# Get property values
|
|
1004
|
-
values_data =
|
|
980
|
+
values_data = db.properties.values(
|
|
1005
981
|
property_id="prop_age",
|
|
1006
982
|
sort="desc", # Sort values in descending order
|
|
1007
983
|
skip=0, # Start from the first value
|
|
@@ -1018,7 +994,7 @@ print(values_data.get('max')) # Maximum value (for numeric properties)
|
|
|
1018
994
|
|
|
1019
995
|
```python
|
|
1020
996
|
# Find all properties
|
|
1021
|
-
all_properties =
|
|
997
|
+
all_properties = db.properties.find()
|
|
1022
998
|
for prop in all_properties:
|
|
1023
999
|
print(f"Property ID: {prop['id']}")
|
|
1024
1000
|
print(f"Name: {prop['name']}")
|
|
@@ -1034,12 +1010,12 @@ query = {
|
|
|
1034
1010
|
},
|
|
1035
1011
|
"limit": 5 # Limit to 5 results
|
|
1036
1012
|
}
|
|
1037
|
-
numeric_score_properties =
|
|
1013
|
+
numeric_score_properties = db.properties.find(query)
|
|
1038
1014
|
|
|
1039
1015
|
# Get values for a specific property
|
|
1040
1016
|
if numeric_score_properties:
|
|
1041
1017
|
first_prop = numeric_score_properties[0]
|
|
1042
|
-
prop_values =
|
|
1018
|
+
prop_values = db.properties.values(
|
|
1043
1019
|
property_id=first_prop['id'],
|
|
1044
1020
|
sort="desc",
|
|
1045
1021
|
limit=50
|
|
@@ -1047,15 +1023,16 @@ if numeric_score_properties:
|
|
|
1047
1023
|
print(f"Values for {first_prop['name']}:")
|
|
1048
1024
|
print(f"Min: {prop_values.get('min')}")
|
|
1049
1025
|
print(f"Max: {prop_values.get('max')}")
|
|
1050
|
-
|
|
1026
|
+
|
|
1051
1027
|
# Detailed property examination
|
|
1052
|
-
detailed_prop =
|
|
1028
|
+
detailed_prop = db.properties.find_by_id(first_prop['id'])
|
|
1053
1029
|
print("Detailed Property Info:", detailed_prop)
|
|
1054
1030
|
```
|
|
1055
1031
|
|
|
1056
1032
|
## Property Types and Structures
|
|
1057
1033
|
|
|
1058
1034
|
RushDB supports the following property types:
|
|
1035
|
+
|
|
1059
1036
|
- `"boolean"`: True/False values
|
|
1060
1037
|
- `"datetime"`: Date and time values
|
|
1061
1038
|
- `"null"`: Null/empty values
|
|
@@ -1063,6 +1040,7 @@ RushDB supports the following property types:
|
|
|
1063
1040
|
- `"string"`: Text values
|
|
1064
1041
|
|
|
1065
1042
|
### Property Structure Example
|
|
1043
|
+
|
|
1066
1044
|
```python
|
|
1067
1045
|
property = {
|
|
1068
1046
|
"id": "prop_unique_id",
|
|
@@ -1085,14 +1063,14 @@ Properties API methods support optional transactions for atomic operations:
|
|
|
1085
1063
|
|
|
1086
1064
|
```python
|
|
1087
1065
|
# Using a transaction
|
|
1088
|
-
with
|
|
1066
|
+
with db.transactions.begin() as transaction:
|
|
1089
1067
|
# Perform multiple property-related operations
|
|
1090
|
-
property_to_delete =
|
|
1068
|
+
property_to_delete = db.properties.find(
|
|
1091
1069
|
{"where": {"name": "temp_property"}},
|
|
1092
1070
|
transaction=transaction
|
|
1093
1071
|
)[0]
|
|
1094
|
-
|
|
1095
|
-
|
|
1072
|
+
|
|
1073
|
+
db.properties.delete(
|
|
1096
1074
|
property_id=property_to_delete['id'],
|
|
1097
1075
|
transaction=transaction
|
|
1098
1076
|
)
|
|
@@ -1106,7 +1084,7 @@ When working with the PropertiesAPI, be prepared to handle potential errors:
|
|
|
1106
1084
|
```python
|
|
1107
1085
|
try:
|
|
1108
1086
|
# Attempt to find or delete a property
|
|
1109
|
-
property_details =
|
|
1087
|
+
property_details = db.properties.find_by_id("non_existent_prop")
|
|
1110
1088
|
except RushDBError as e:
|
|
1111
1089
|
print(f"Error: {e}")
|
|
1112
1090
|
print(f"Error Details: {e.details}")
|