File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919# Have fresh data for each start
2020objectbox .Store .remove_db_files ("objectbox" )
2121
22- @Entity (id = 1 , uid = 1 )
22+ @Entity ()
2323class DocumentEmbedding :
24- id = Id (id = 1 , uid = 1001 )
25- document = String (id = 2 , uid = 1002 )
26- embedding = Float32Vector (id = 3 , uid = 1003 , index = HnswIndex (
27- id = 3 , uid = 10001 ,
24+ id = Id ()
25+ document = String ()
26+ embedding = Float32Vector (index = HnswIndex (
2827 dimensions = 1024 ,
2928 distance_type = VectorDistanceType .COSINE
3029 ))
3130
3231model = Model ()
33- model .entity (DocumentEmbedding , last_property_id = IdUid (3 , 1003 ))
34- model .last_entity_id = IdUid (1 , 1 )
35- model .last_index_id = IdUid (3 ,10001 )
32+ model .entity (DocumentEmbedding )
33+ sync_model (model )
3634
3735store = objectbox .Store (model = model )
3836box = store .box (DocumentEmbedding )
Original file line number Diff line number Diff line change 11from objectbox .model import *
2+ from objectbox .model .sync_model import sync_model
23
3-
4- @Entity (id = 1 , uid = 1 )
4+ @Entity ()
55class Task :
6- id = Id (id = 1 , uid = 1001 )
7- text = String (id = 2 , uid = 1002 )
6+ id = Id ()
7+ text = String ()
88
9- date_created = Date (py_type = int , id = 3 , uid = 1003 )
10- date_finished = Date (py_type = int , id = 4 , uid = 1004 )
9+ date_created = Date (py_type = int )
10+ date_finished = Date (py_type = int )
1111
1212
1313def get_objectbox_model ():
1414 m = Model ()
15- m .entity (Task , last_property_id = IdUid ( 4 , 1004 ) )
16- m . last_entity_id = IdUid ( 2 , 2 )
15+ m .entity (Task )
16+ sync_model ( m )
1717 return m
Original file line number Diff line number Diff line change 11from objectbox .model import *
2+ from objectbox .model .properties import *
3+ from objectbox .model .sync_model import sync_model
4+ import objectbox
5+ import numpy as np
26
3- @Entity (id = 1 , uid = 1 )
7+
8+ @Entity ()
49class City :
5- id = Id (id = 1 , uid = 1001 )
6- name = String (id = 2 , uid = 1002 )
7- location = Float32Vector (id = 3 , uid = 1003 , index = HnswIndex (
8- id = 3 , uid = 10001 ,
10+ id = Id ()
11+ name = String ()
12+ location = Float32Vector (index = HnswIndex (
913 dimensions = 2 ,
1014 distance_type = VectorDistanceType .EUCLIDEAN
1115 ))
1216
1317def get_objectbox_model ():
1418 m = Model ()
15- m .entity (City , last_property_id = IdUid (3 , 1003 ))
16- m .last_entity_id = IdUid (1 , 1 )
17- m .last_index_id = IdUid (3 , 10001 )
19+ m .entity (City )
20+ sync_model (m )
1821 return m
You can’t perform that action at this time.
0 commit comments