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
Copy file name to clipboardExpand all lines: README.md
+289-6Lines changed: 289 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1017,7 +1017,8 @@ Records can be manipulated within transactions for atomic operations:
1017
1017
1018
1018
```python
1019
1019
# Start a transaction
1020
-
with db.transactions.begin() as transaction:
1020
+
transaction = db.transactions.begin()
1021
+
try:
1021
1022
# Create user
1022
1023
user = db.records.create(
1023
1024
"USER",
@@ -1044,8 +1045,24 @@ with db.transactions.begin() as transaction:
1044
1045
transaction=transaction
1045
1046
)
1046
1047
1047
-
# Transaction will automatically commit if no errors occur
1048
-
# If an error occurs, it will automatically rollback
1048
+
# Explicitly commit the transaction to make changes permanent
1049
+
transaction.commit()
1050
+
exceptExceptionas e:
1051
+
# Rollback if any error occurs
1052
+
transaction.rollback()
1053
+
raise e
1054
+
1055
+
# Alternative: Using context manager
1056
+
with db.transactions.begin() as transaction:
1057
+
# Perform operations...
1058
+
user = db.records.create(
1059
+
"USER",
1060
+
{"name": "John Doe"},
1061
+
transaction=transaction
1062
+
)
1063
+
1064
+
# Must explicitly commit - transactions are NOT automatically committed
1065
+
transaction.commit()
1049
1066
```
1050
1067
1051
1068
---
@@ -1280,8 +1297,9 @@ property_with_value = {
1280
1297
Properties API methods support optional transactions for atomic operations:
1281
1298
1282
1299
```python
1283
-
# Using a transaction
1284
-
with db.transactions.begin() as transaction:
1300
+
# Using a transaction with explicit commit
1301
+
transaction = db.transactions.begin()
1302
+
try:
1285
1303
# Perform multiple property-related operations
1286
1304
property_to_delete = db.properties.find(
1287
1305
{"where": {"name": "temp_property"}},
@@ -1292,7 +1310,29 @@ with db.transactions.begin() as transaction:
1292
1310
property_id=property_to_delete['id'],
1293
1311
transaction=transaction
1294
1312
)
1295
-
# Transaction will automatically commit if no errors occur
1313
+
1314
+
# Explicitly commit the transaction
1315
+
transaction.commit()
1316
+
exceptExceptionas e:
1317
+
# Rollback if any error occurs
1318
+
transaction.rollback()
1319
+
raise e
1320
+
1321
+
# Alternative: Using context manager (auto-rollback on error)
1322
+
with db.transactions.begin() as transaction:
1323
+
# Perform operations
1324
+
property_to_delete = db.properties.find(
1325
+
{"where": {"name": "temp_property"}},
1326
+
transaction=transaction
1327
+
)[0]
1328
+
1329
+
db.properties.delete(
1330
+
property_id=property_to_delete['id'],
1331
+
transaction=transaction
1332
+
)
1333
+
1334
+
# Must explicitly commit - transactions are NOT automatically committed
1335
+
transaction.commit()
1296
1336
```
1297
1337
1298
1338
## Error Handling
@@ -1307,3 +1347,246 @@ except RushDBError as e:
1307
1347
print(f"Error: {e}")
1308
1348
print(f"Error Details: {e.details}")
1309
1349
```
1350
+
1351
+
---
1352
+
1353
+
# LabelsAPI Documentation
1354
+
1355
+
The `LabelsAPI`class provides methods for discovering and working with record labels in RushDB. Labels are used to categorize andtype records, similar to table names in relational databases.
1356
+
1357
+
## Class Definition
1358
+
1359
+
```python
1360
+
class LabelsAPI(BaseAPI):
1361
+
```
1362
+
1363
+
## Methods
1364
+
1365
+
### find()
1366
+
1367
+
Discovers labels (record types) that exist in the database and can optionally filter them based on search criteria.
1368
+
1369
+
**Signature:**
1370
+
1371
+
```python
1372
+
def find(
1373
+
self,
1374
+
search_query: Optional[SearchQuery] =None,
1375
+
transaction: Optional[Transaction] =None
1376
+
) -> Dict[str, int]
1377
+
```
1378
+
1379
+
**Arguments:**
1380
+
1381
+
-`search_query` (Optional[SearchQuery]): Search criteria to filter labels
The `RelationshipsAPI`class provides functionality for querying and analyzing relationships between records in RushDB. Relationships represent connections or associations between different records.
1439
+
1440
+
## Class Definition
1441
+
1442
+
```python
1443
+
class RelationshipsAPI(BaseAPI):
1444
+
```
1445
+
1446
+
## Methods
1447
+
1448
+
### find()
1449
+
1450
+
Search forand retrieve relationships matching the specified criteria with support for pagination and transactions.
0 commit comments