rushdb 0.1.0__tar.gz → 0.3.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/PKG-INFO ADDED
@@ -0,0 +1,1114 @@
1
+ Metadata-Version: 2.1
2
+ Name: rushdb
3
+ Version: 0.3.0
4
+ Summary: RushDB Python SDK
5
+ Home-page: https://github.com/rushdb/rushdb-python
6
+ License: Apache-2.0
7
+ Keywords: database,graph database,instant database,instant-database,instantdatabase,instant db,instant-db,instantdb,neo4j,cypher,ai,ai database,etl,data-pipeline,data science,data-science,data management,data-management,machine learning,machine-learning,persistence,db,graph,graphs,graph-database,self-hosted,rush-db,rush db,rushdb
8
+ Author: RushDB Team
9
+ Author-email: hi@rushdb.com
10
+ Requires-Python: >=3.8,<4.0
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
19
+ Requires-Dist: requests (>=2.31.0,<3.0.0)
20
+ Project-URL: Documentation, https://docs.rushdb.com
21
+ Project-URL: Repository, https://github.com/rushdb/rushdb-python
22
+ Description-Content-Type: text/markdown
23
+
24
+ <div align="center">
25
+
26
+ ![RushDB Logo](https://raw.githubusercontent.com/rush-db/rushdb/main/rushdb-logo.svg)
27
+
28
+ # RushDB Python SDK
29
+ ![PyPI - Version](https://img.shields.io/pypi/v/rushdb)
30
+
31
+ ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/rushdb)
32
+
33
+ ![PyPI - License](https://img.shields.io/pypi/l/rushdb)
34
+
35
+ RushDB is an instant database for modern apps and DS/ML ops built on top of Neo4j.
36
+
37
+ It automates data normalization, manages relationships, and infers data types, enabling developers to focus on building features rather than wrestling with data.
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
+ </div>
41
+
42
+ ---
43
+
44
+ ## Installation
45
+
46
+ Install the RushDB Python SDK via pip:
47
+
48
+
49
+ ```sh
50
+ pip install rushdb
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Usage
56
+
57
+ ### **1. Setup SDK**
58
+
59
+ ```python
60
+ from rushdb import RushDB
61
+
62
+ db = RushDB("API_TOKEN", base_url="https://api.rushdb.com")
63
+ ```
64
+
65
+ ---
66
+
67
+ ### **2. Push any JSON data**
68
+
69
+
70
+ ```python
71
+ company_data = {
72
+ "name": "Google LLC",
73
+ "address": "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
74
+ "foundedAt": "1998-09-04T00:00:00.000Z",
75
+ "rating": 4.9,
76
+ "DEPARTMENT": [{
77
+ "name": "Research & Development",
78
+ "description": "Innovating and creating advanced technologies for AI, cloud computing, and consumer devices.",
79
+ "PROJECT": [{
80
+ "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
+ "EMPLOYEE": [{
85
+ "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
90
+ }]
91
+ }]
92
+ }]
93
+ }
94
+
95
+ db.records.create_many("COMPANY", company_data)
96
+ ```
97
+
98
+ This operation will create 4 Records with proper data types and relationships according to this structure:
99
+
100
+ ```cypher
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
+ ```
109
+
110
+ ---
111
+
112
+ ### **3. Find Records by specific criteria**
113
+
114
+ ```python
115
+ query = {
116
+ "labels": ["EMPLOYEE"],
117
+ "where": {
118
+ "position": {"$contains": "AI"},
119
+ "PROJECT": {
120
+ "DEPARTMENT": {
121
+ "COMPANY": {
122
+ "rating": {"$gte": 4}
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+ matched_employees = db.records.find(query)
130
+
131
+ company = db.records.find_uniq("COMPANY", {"where": {"name": "Google LLC"}})
132
+ ```
133
+
134
+ ---
135
+
136
+
137
+ # Documentation
138
+
139
+ # RecordsAPI Documentation
140
+
141
+ The `RecordsAPI` class provides methods for managing records in RushDB. It handles record creation, updates, deletion, searching, and relationship management.
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
+ ```
236
+
237
+ ### set()
238
+
239
+ Updates a record by ID, replacing all data.
240
+
241
+ **Signature:**
242
+ ```python
243
+ def set(
244
+ self,
245
+ record_id: str,
246
+ data: Dict[str, Any],
247
+ transaction: Optional[Transaction] = None
248
+ ) -> Dict[str, str]
249
+ ```
250
+
251
+ **Arguments:**
252
+ - `record_id` (str): ID of the record to update
253
+ - `data` (Dict[str, Any]): New record data
254
+ - `transaction` (Optional[Transaction]): Optional transaction object
255
+
256
+ **Returns:**
257
+ - `Dict[str, str]`: Response data
258
+
259
+ **Example:**
260
+ ```python
261
+ # Update entire record data
262
+ new_data = {
263
+ "name": "Updated Company Name",
264
+ "rating": 5.0
265
+ }
266
+
267
+ response = db.records.set(
268
+ record_id="record-123",
269
+ data=new_data
270
+ )
271
+ ```
272
+
273
+ ### update()
274
+
275
+ Updates specific fields of a record by ID.
276
+
277
+ **Signature:**
278
+ ```python
279
+ def update(
280
+ self,
281
+ record_id: str,
282
+ data: Dict[str, Any],
283
+ transaction: Optional[Transaction] = None
284
+ ) -> Dict[str, str]
285
+ ```
286
+
287
+ **Arguments:**
288
+ - `record_id` (str): ID of the record to update
289
+ - `data` (Dict[str, Any]): Partial record data to update
290
+ - `transaction` (Optional[Transaction]): Optional transaction object
291
+
292
+ **Returns:**
293
+ - `Dict[str, str]`: Response data
294
+
295
+ **Example:**
296
+ ```python
297
+ # Update specific fields
298
+ updates = {
299
+ "rating": 4.8,
300
+ "status": "active"
301
+ }
302
+
303
+ response = db.records.update(
304
+ record_id="record-123",
305
+ data=updates
306
+ )
307
+ ```
308
+
309
+ ### find()
310
+
311
+ Searches for records matching specified criteria.
312
+
313
+ **Signature:**
314
+ ```python
315
+ def find(
316
+ self,
317
+ query: Optional[SearchQuery] = None,
318
+ record_id: Optional[str] = None,
319
+ transaction: Optional[Transaction] = None
320
+ ) -> List[Record]
321
+ ```
322
+
323
+ **Arguments:**
324
+ - `query` (Optional[SearchQuery]): Search query parameters
325
+ - `record_id` (Optional[str]): Optional record ID to search from
326
+ - `transaction` (Optional[Transaction]): Optional transaction object
327
+
328
+ **Returns:**
329
+ - `List[Record]`: List of matching records
330
+
331
+ **Example:**
332
+ ```python
333
+ # Search for records with complex criteria
334
+ query = {
335
+ "where": {
336
+ "$and": [
337
+ {"age": {"$gte": 18}},
338
+ {"status": "active"},
339
+ {"department": "Engineering"}
340
+ ]
341
+ },
342
+ "orderBy": {"created_at": "desc"},
343
+ "limit": 10
344
+ }
345
+
346
+ records = db.records.find(query=query)
347
+ ```
348
+
349
+ ### delete()
350
+
351
+ Deletes records matching a query.
352
+
353
+ **Signature:**
354
+ ```python
355
+ def delete(
356
+ self,
357
+ query: SearchQuery,
358
+ transaction: Optional[Transaction] = None
359
+ ) -> Dict[str, str]
360
+ ```
361
+
362
+ **Arguments:**
363
+ - `query` (SearchQuery): Query to match records for deletion
364
+ - `transaction` (Optional[Transaction]): Optional transaction object
365
+
366
+ **Returns:**
367
+ - `Dict[str, str]`: Response data
368
+
369
+ **Example:**
370
+ ```python
371
+ # Delete records matching criteria
372
+ query = {
373
+ "where": {
374
+ "status": "inactive",
375
+ "lastActive": {"$lt": "2023-01-01"}
376
+ }
377
+ }
378
+
379
+ response = db.records.delete(query)
380
+ ```
381
+
382
+ ### delete_by_id()
383
+
384
+ Deletes one or more records by ID.
385
+
386
+ **Signature:**
387
+ ```python
388
+ def delete_by_id(
389
+ self,
390
+ id_or_ids: Union[str, List[str]],
391
+ transaction: Optional[Transaction] = None
392
+ ) -> Dict[str, str]
393
+ ```
394
+
395
+ **Arguments:**
396
+ - `id_or_ids` (Union[str, List[str]]): Single ID or list of IDs to delete
397
+ - `transaction` (Optional[Transaction]): Optional transaction object
398
+
399
+ **Returns:**
400
+ - `Dict[str, str]`: Response data
401
+
402
+ **Example:**
403
+ ```python
404
+ # Delete single record
405
+ response = db.records.delete_by_id("record-123")
406
+
407
+ # Delete multiple records
408
+ response = db.records.delete_by_id([
409
+ "record-123",
410
+ "record-456",
411
+ "record-789"
412
+ ])
413
+ ```
414
+
415
+ ### attach()
416
+
417
+ Creates relationships between records.
418
+
419
+ **Signature:**
420
+ ```python
421
+ def attach(
422
+ self,
423
+ source: Union[str, Dict[str, Any]],
424
+ target: Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]],
425
+ options: Optional[RelationshipOptions] = None,
426
+ transaction: Optional[Transaction] = None
427
+ ) -> Dict[str, str]
428
+ ```
429
+
430
+ **Arguments:**
431
+ - `source` (Union[str, Dict[str, Any]]): Source record ID or data
432
+ - `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
433
+ - `options` (Optional[RelationshipOptions]): Relationship options
434
+ - `direction` (Optional[Literal["in", "out"]]): Relationship direction
435
+ - `type` (Optional[str]): Relationship type
436
+ - `transaction` (Optional[Transaction]): Optional transaction object
437
+
438
+ **Returns:**
439
+ - `Dict[str, str]`: Response data
440
+
441
+ **Example:**
442
+ ```python
443
+ # Create relationship between records
444
+ options = RelationshipOptions(
445
+ type="HAS_EMPLOYEE",
446
+ direction="out"
447
+ )
448
+
449
+ response = db.records.attach(
450
+ source="company-123",
451
+ target=["employee-456", "employee-789"],
452
+ options=options
453
+ )
454
+ ```
455
+
456
+ ### detach()
457
+
458
+ Removes relationships between records.
459
+
460
+ **Signature:**
461
+ ```python
462
+ def detach(
463
+ self,
464
+ source: Union[str, Dict[str, Any]],
465
+ target: Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]],
466
+ options: Optional[RelationshipDetachOptions] = None,
467
+ transaction: Optional[Transaction] = None
468
+ ) -> Dict[str, str]
469
+ ```
470
+
471
+ **Arguments:**
472
+ - `source` (Union[str, Dict[str, Any]]): Source record ID or data
473
+ - `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
474
+ - `options` (Optional[RelationshipDetachOptions]): Detach options
475
+ - `direction` (Optional[Literal["in", "out"]]): Relationship direction
476
+ - `typeOrTypes` (Optional[Union[str, List[str]]]): Relationship type(s)
477
+ - `transaction` (Optional[Transaction]): Optional transaction object
478
+
479
+ **Returns:**
480
+ - `Dict[str, str]`: Response data
481
+
482
+ **Example:**
483
+ ```python
484
+ # Remove relationships between records
485
+ options = RelationshipDetachOptions(
486
+ typeOrTypes=["HAS_EMPLOYEE", "MANAGES"],
487
+ direction="out"
488
+ )
489
+
490
+ response = db.records.detach(
491
+ source="company-123",
492
+ target="employee-456",
493
+ options=options
494
+ )
495
+ ```
496
+
497
+ ### import_csv()
498
+
499
+ Imports records from CSV data.
500
+
501
+ **Signature:**
502
+ ```python
503
+ def import_csv(
504
+ self,
505
+ label: str,
506
+ csv_data: Union[str, bytes],
507
+ options: Optional[Dict[str, bool]] = None,
508
+ transaction: Optional[Transaction] = None
509
+ ) -> List[Dict[str, Any]]
510
+ ```
511
+
512
+ **Arguments:**
513
+ - `label` (str): Label for imported records
514
+ - `csv_data` (Union[str, bytes]): CSV data to import
515
+ - `options` (Optional[Dict[str, bool]]): Import options
516
+ - `transaction` (Optional[Transaction]): Optional transaction object
517
+
518
+ **Returns:**
519
+ - `List[Dict[str, Any]]`: Imported records data
520
+
521
+ **Example:**
522
+ ```python
523
+ # Import records from CSV
524
+ csv_data = """name,age,department,role
525
+ John Doe,30,Engineering,Senior Engineer
526
+ Jane Smith,28,Product,Product Manager
527
+ Bob Wilson,35,Engineering,Tech Lead"""
528
+
529
+ records = db.records.import_csv(
530
+ label="EMPLOYEE",
531
+ csv_data=csv_data,
532
+ options={"returnResult": True, "suggestTypes": True}
533
+ )
534
+ ```
535
+
536
+ ---
537
+
538
+ # Record Class Documentation
539
+
540
+ The `Record` class represents a record in RushDB and provides methods for manipulating individual records, including updates, relationships, and deletions.
541
+
542
+ ## Class Definition
543
+
544
+ ```python
545
+ class Record:
546
+ def __init__(self, client: "RushDB", data: Union[Dict[str, Any], None] = None)
547
+ ```
548
+
549
+ ## Properties
550
+
551
+ ### id
552
+
553
+ Gets the record's unique identifier.
554
+
555
+ **Type:** `str`
556
+
557
+ **Example:**
558
+ ```python
559
+ record = db.records.create("USER", {"name": "John"})
560
+ print(record.id) # e.g., "1234abcd-5678-..."
561
+ ```
562
+
563
+ ### proptypes
564
+
565
+ Gets the record's property types.
566
+
567
+ **Type:** `str`
568
+
569
+ **Example:**
570
+ ```python
571
+ record = db.records.create("USER", {"name": "John", "age": 25})
572
+ print(record.proptypes) # Returns property type definitions
573
+ ```
574
+
575
+ ### label
576
+
577
+ Gets the record's label.
578
+
579
+ **Type:** `str`
580
+
581
+ **Example:**
582
+ ```python
583
+ record = db.records.create("USER", {"name": "John"})
584
+ print(record.label) # "USER"
585
+ ```
586
+
587
+ ### timestamp
588
+
589
+ Gets the record's creation timestamp from its ID.
590
+
591
+ **Type:** `int`
592
+
593
+ **Example:**
594
+ ```python
595
+ record = db.records.create("USER", {"name": "John"})
596
+ print(record.timestamp) # Unix timestamp in milliseconds
597
+ ```
598
+
599
+ ### date
600
+
601
+ Gets the record's creation date.
602
+
603
+ **Type:** `datetime`
604
+
605
+ **Example:**
606
+ ```python
607
+ record = db.records.create("USER", {"name": "John"})
608
+ print(record.date) # datetime object
609
+ ```
610
+
611
+ ## Methods
612
+
613
+ ### set()
614
+
615
+ Updates all data for the record.
616
+
617
+ **Signature:**
618
+ ```python
619
+ def set(
620
+ self,
621
+ data: Dict[str, Any],
622
+ transaction: Optional[Transaction] = None
623
+ ) -> Dict[str, str]
624
+ ```
625
+
626
+ **Arguments:**
627
+ - `data` (Dict[str, Any]): New record data
628
+ - `transaction` (Optional[Transaction]): Optional transaction object
629
+
630
+ **Returns:**
631
+ - `Dict[str, str]`: Response data
632
+
633
+ **Example:**
634
+ ```python
635
+ record = db.records.create("USER", {"name": "John"})
636
+ response = record.set({
637
+ "name": "John Doe",
638
+ "email": "john@example.com",
639
+ "age": 30
640
+ })
641
+ ```
642
+
643
+ ### update()
644
+
645
+ Updates specific fields of the record.
646
+
647
+ **Signature:**
648
+ ```python
649
+ def update(
650
+ self,
651
+ data: Dict[str, Any],
652
+ transaction: Optional[Transaction] = None
653
+ ) -> Dict[str, str]
654
+ ```
655
+
656
+ **Arguments:**
657
+ - `data` (Dict[str, Any]): Partial record data to update
658
+ - `transaction` (Optional[Transaction]): Optional transaction object
659
+
660
+ **Returns:**
661
+ - `Dict[str, str]`: Response data
662
+
663
+ **Example:**
664
+ ```python
665
+ record = db.records.create("USER", {
666
+ "name": "John",
667
+ "email": "john@example.com"
668
+ })
669
+ response = record.update({
670
+ "email": "john.doe@example.com"
671
+ })
672
+ ```
673
+
674
+ ### attach()
675
+
676
+ Creates relationships with other records.
677
+
678
+ **Signature:**
679
+ ```python
680
+ def attach(
681
+ self,
682
+ target: Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], "Record", List["Record"]],
683
+ options: Optional[RelationshipOptions] = None,
684
+ transaction: Optional[Transaction] = None
685
+ ) -> Dict[str, str]
686
+ ```
687
+
688
+ **Arguments:**
689
+ - `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
690
+ - `options` (Optional[RelationshipOptions]): Relationship options
691
+ - `direction` (Optional[Literal["in", "out"]]): Relationship direction
692
+ - `type` (Optional[str]): Relationship type
693
+ - `transaction` (Optional[Transaction]): Optional transaction object
694
+
695
+ **Returns:**
696
+ - `Dict[str, str]`: Response data
697
+
698
+ **Example:**
699
+ ```python
700
+ # Create two records
701
+ user = db.records.create("USER", {"name": "John"})
702
+ group = db.records.create("GROUP", {"name": "Admins"})
703
+
704
+ # Attach user to group
705
+ response = user.attach(
706
+ target=group,
707
+ options=RelationshipOptions(
708
+ type="BELONGS_TO",
709
+ direction="out"
710
+ )
711
+ )
712
+ ```
713
+
714
+ ### detach()
715
+
716
+ Removes relationships with other records.
717
+
718
+ **Signature:**
719
+ ```python
720
+ def detach(
721
+ self,
722
+ target: Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], "Record", List["Record"]],
723
+ options: Optional[RelationshipDetachOptions] = None,
724
+ transaction: Optional[Transaction] = None
725
+ ) -> Dict[str, str]
726
+ ```
727
+
728
+ **Arguments:**
729
+ - `target` (Union[str, List[str], Dict[str, Any], List[Dict[str, Any]], Record, List[Record]]): Target record(s)
730
+ - `options` (Optional[RelationshipDetachOptions]): Detach options
731
+ - `direction` (Optional[Literal["in", "out"]]): Relationship direction
732
+ - `typeOrTypes` (Optional[Union[str, List[str]]]): Relationship type(s)
733
+ - `transaction` (Optional[Transaction]): Optional transaction object
734
+
735
+ **Returns:**
736
+ - `Dict[str, str]`: Response data
737
+
738
+ **Example:**
739
+ ```python
740
+ # Detach user from group
741
+ response = user.detach(
742
+ target=group,
743
+ options=RelationshipDetachOptions(
744
+ typeOrTypes="BELONGS_TO",
745
+ direction="out"
746
+ )
747
+ )
748
+ ```
749
+
750
+ ### delete()
751
+
752
+ Deletes the record.
753
+
754
+ **Signature:**
755
+ ```python
756
+ def delete(
757
+ self,
758
+ transaction: Optional[Transaction] = None
759
+ ) -> Dict[str, str]
760
+ ```
761
+
762
+ **Arguments:**
763
+ - `transaction` (Optional[Transaction]): Optional transaction object
764
+
765
+ **Returns:**
766
+ - `Dict[str, str]`: Response data
767
+
768
+ **Example:**
769
+ ```python
770
+ user = db.records.create("USER", {"name": "John"})
771
+ response = user.delete()
772
+ ```
773
+
774
+ ## Complete Usage Example
775
+
776
+ Here's a comprehensive example demonstrating various Record operations:
777
+
778
+ ```python
779
+ # Create a new record
780
+ user = db.records.create("USER", {
781
+ "name": "John Doe",
782
+ "email": "john@example.com",
783
+ "age": 30
784
+ })
785
+
786
+ # Access properties
787
+ print(f"Record ID: {user.id}")
788
+ print(f"Label: {user.label}")
789
+ print(f"Created at: {user.date}")
790
+
791
+ # Update record data
792
+ user.update({
793
+ "age": 31,
794
+ "title": "Senior Developer"
795
+ })
796
+
797
+ # Create related records
798
+ department = db.records.create("DEPARTMENT", {
799
+ "name": "Engineering"
800
+ })
801
+
802
+ project = db.records.create("PROJECT", {
803
+ "name": "Secret Project"
804
+ })
805
+
806
+ # Create relationships
807
+ user.attach(
808
+ target=department,
809
+ options=RelationshipOptions(
810
+ type="BELONGS_TO",
811
+ direction="out"
812
+ )
813
+ )
814
+
815
+ user.attach(
816
+ target=project,
817
+ options=RelationshipOptions(
818
+ type="WORKS_ON",
819
+ direction="out"
820
+ )
821
+ )
822
+
823
+ # Remove relationship
824
+ user.detach(
825
+ target=project,
826
+ options=RelationshipDetachOptions(
827
+ typeOrTypes="WORKS_ON",
828
+ direction="out"
829
+ )
830
+ )
831
+
832
+ # Delete record
833
+ user.delete()
834
+ ```
835
+
836
+ ## Working with Transactions
837
+
838
+ Records can be manipulated within transactions for atomic operations:
839
+
840
+ ```python
841
+ # Start a transaction
842
+ with db.transactions.begin() as transaction:
843
+ # Create user
844
+ user = db.records.create(
845
+ "USER",
846
+ {"name": "John Doe"},
847
+ transaction=transaction
848
+ )
849
+
850
+ # Update user
851
+ user.update(
852
+ {"status": "active"},
853
+ transaction=transaction
854
+ )
855
+
856
+ # Create and attach department
857
+ dept = db.records.create(
858
+ "DEPARTMENT",
859
+ {"name": "Engineering"},
860
+ transaction=transaction
861
+ )
862
+
863
+ user.attach(
864
+ target=dept,
865
+ options=RelationshipOptions(type="BELONGS_TO"),
866
+ transaction=transaction
867
+ )
868
+
869
+ # Transaction will automatically commit if no errors occur
870
+ # If an error occurs, it will automatically rollback
871
+ ```
872
+
873
+ ---
874
+
875
+ # PropertiesAPI Documentation
876
+
877
+ The `PropertiesAPI` class provides methods for managing and querying properties in RushDB.
878
+
879
+ ## Class Definition
880
+
881
+ ```python
882
+ class PropertiesAPI(BaseAPI):
883
+ ```
884
+
885
+ ## Methods
886
+
887
+ ### find()
888
+
889
+ Retrieves a list of properties based on optional search criteria.
890
+
891
+ **Signature:**
892
+ ```python
893
+ def find(
894
+ self,
895
+ query: Optional[SearchQuery] = None,
896
+ transaction: Optional[Transaction] = None
897
+ ) -> List[Property]
898
+ ```
899
+
900
+ **Arguments:**
901
+ - `query` (Optional[SearchQuery]): Search query parameters for filtering properties
902
+ - `transaction` (Optional[Transaction]): Optional transaction object
903
+
904
+ **Returns:**
905
+ - `List[Property]`: List of properties matching the search criteria
906
+
907
+ **Example:**
908
+ ```python
909
+ # Find all properties
910
+ properties = client.properties.find()
911
+
912
+ # Find properties with specific criteria
913
+ query = {
914
+ "where": {
915
+ "name": {"$startsWith": "user_"}, # Properties starting with 'user_'
916
+ "type": "string" # Only string type properties
917
+ },
918
+ "limit": 10 # Limit to 10 results
919
+ }
920
+ filtered_properties = client.properties.find(query)
921
+ ```
922
+
923
+ ### find_by_id()
924
+
925
+ Retrieves a specific property by its ID.
926
+
927
+ **Signature:**
928
+ ```python
929
+ def find_by_id(
930
+ self,
931
+ property_id: str,
932
+ transaction: Optional[Transaction] = None
933
+ ) -> Property
934
+ ```
935
+
936
+ **Arguments:**
937
+ - `property_id` (str): Unique identifier of the property
938
+ - `transaction` (Optional[Transaction]): Optional transaction object
939
+
940
+ **Returns:**
941
+ - `Property`: Property details
942
+
943
+ **Example:**
944
+ ```python
945
+ # Retrieve a specific property by ID
946
+ property_details = client.properties.find_by_id("prop_123456")
947
+ ```
948
+
949
+ ### delete()
950
+
951
+ Deletes a property by its ID.
952
+
953
+ **Signature:**
954
+ ```python
955
+ def delete(
956
+ self,
957
+ property_id: str,
958
+ transaction: Optional[Transaction] = None
959
+ ) -> None
960
+ ```
961
+
962
+ **Arguments:**
963
+ - `property_id` (str): Unique identifier of the property to delete
964
+ - `transaction` (Optional[Transaction]): Optional transaction object
965
+
966
+ **Returns:**
967
+ - `None`
968
+
969
+ **Example:**
970
+ ```python
971
+ # Delete a property
972
+ client.properties.delete("prop_123456")
973
+ ```
974
+
975
+ ### values()
976
+
977
+ Retrieves values for a specific property with optional sorting and pagination.
978
+
979
+ **Signature:**
980
+ ```python
981
+ def values(
982
+ self,
983
+ property_id: str,
984
+ sort: Optional[Literal["asc", "desc"]] = None,
985
+ skip: Optional[int] = None,
986
+ limit: Optional[int] = None,
987
+ transaction: Optional[Transaction] = None
988
+ ) -> PropertyValuesData
989
+ ```
990
+
991
+ **Arguments:**
992
+ - `property_id` (str): Unique identifier of the property
993
+ - `sort` (Optional[Literal["asc", "desc"]]): Sort order of values
994
+ - `skip` (Optional[int]): Number of values to skip (for pagination)
995
+ - `limit` (Optional[int]): Maximum number of values to return
996
+ - `transaction` (Optional[Transaction]): Optional transaction object
997
+
998
+ **Returns:**
999
+ - `PropertyValuesData`: Property values data, including optional min/max and list of values
1000
+
1001
+ **Example:**
1002
+ ```python
1003
+ # Get property values
1004
+ values_data = client.properties.values(
1005
+ property_id="prop_age",
1006
+ sort="desc", # Sort values in descending order
1007
+ skip=0, # Start from the first value
1008
+ limit=100 # Return up to 100 values
1009
+ )
1010
+
1011
+ # Access values
1012
+ print(values_data.get('values', [])) # List of property values
1013
+ print(values_data.get('min')) # Minimum value (for numeric properties)
1014
+ print(values_data.get('max')) # Maximum value (for numeric properties)
1015
+ ```
1016
+
1017
+ ## Comprehensive Usage Example
1018
+
1019
+ ```python
1020
+ # Find all properties
1021
+ all_properties = client.properties.find()
1022
+ for prop in all_properties:
1023
+ print(f"Property ID: {prop['id']}")
1024
+ print(f"Name: {prop['name']}")
1025
+ print(f"Type: {prop['type']}")
1026
+ print(f"Metadata: {prop.get('metadata', 'No metadata')}")
1027
+ print("---")
1028
+
1029
+ # Detailed property search
1030
+ query = {
1031
+ "where": {
1032
+ "type": "number", # Only numeric properties
1033
+ "name": {"$contains": "score"} # Properties with 'score' in name
1034
+ },
1035
+ "limit": 5 # Limit to 5 results
1036
+ }
1037
+ numeric_score_properties = client.properties.find(query)
1038
+
1039
+ # Get values for a specific property
1040
+ if numeric_score_properties:
1041
+ first_prop = numeric_score_properties[0]
1042
+ prop_values = client.properties.values(
1043
+ property_id=first_prop['id'],
1044
+ sort="desc",
1045
+ limit=50
1046
+ )
1047
+ print(f"Values for {first_prop['name']}:")
1048
+ print(f"Min: {prop_values.get('min')}")
1049
+ print(f"Max: {prop_values.get('max')}")
1050
+
1051
+ # Detailed property examination
1052
+ detailed_prop = client.properties.find_by_id(first_prop['id'])
1053
+ print("Detailed Property Info:", detailed_prop)
1054
+ ```
1055
+
1056
+ ## Property Types and Structures
1057
+
1058
+ RushDB supports the following property types:
1059
+ - `"boolean"`: True/False values
1060
+ - `"datetime"`: Date and time values
1061
+ - `"null"`: Null/empty values
1062
+ - `"number"`: Numeric values
1063
+ - `"string"`: Text values
1064
+
1065
+ ### Property Structure Example
1066
+ ```python
1067
+ property = {
1068
+ "id": "prop_unique_id",
1069
+ "name": "user_score",
1070
+ "type": "number",
1071
+ "metadata": Optional[str] # Optional additional information
1072
+ }
1073
+
1074
+ property_with_value = {
1075
+ "id": "prop_unique_id",
1076
+ "name": "user_score",
1077
+ "type": "number",
1078
+ "value": 95.5 # Actual property value
1079
+ }
1080
+ ```
1081
+
1082
+ ## Transactions
1083
+
1084
+ Properties API methods support optional transactions for atomic operations:
1085
+
1086
+ ```python
1087
+ # Using a transaction
1088
+ with client.transactions.begin() as transaction:
1089
+ # Perform multiple property-related operations
1090
+ property_to_delete = client.properties.find(
1091
+ {"where": {"name": "temp_property"}},
1092
+ transaction=transaction
1093
+ )[0]
1094
+
1095
+ client.properties.delete(
1096
+ property_id=property_to_delete['id'],
1097
+ transaction=transaction
1098
+ )
1099
+ # Transaction will automatically commit if no errors occur
1100
+ ```
1101
+
1102
+ ## Error Handling
1103
+
1104
+ When working with the PropertiesAPI, be prepared to handle potential errors:
1105
+
1106
+ ```python
1107
+ try:
1108
+ # Attempt to find or delete a property
1109
+ property_details = client.properties.find_by_id("non_existent_prop")
1110
+ except RushDBError as e:
1111
+ print(f"Error: {e}")
1112
+ print(f"Error Details: {e.details}")
1113
+ ```
1114
+