1+ from objectbox .model .entity import _Entity
2+ from objectbox .objectbox import ObjectBox
3+ from objectbox .query import Query
4+ from objectbox .c import *
5+
6+
7+ class QueryBuilder :
8+ def __init__ (self , ob : ObjectBox , box : 'Box' , entity : '_Entity' , condition : 'QueryCondition' ):
9+ if not isinstance (entity , _Entity ):
10+ raise Exception ("Given type is not an Entity" )
11+ self ._box = box
12+ self ._entity = entity
13+ self ._condition = condition
14+ self ._c_builder = obx_query_builder (ob ._c_store , entity .id )
15+
16+ def close (self ) -> int :
17+ return obx_qb_close (self )
18+
19+ def error_code (self ) -> int :
20+ return obx_qb_error_code (self )
21+
22+ def error_message (self ) -> str :
23+ return obx_qb_error_message (self )
24+
25+ def equals_string (self , property_id : int , value : str , case_sensitive : bool ):
26+ obx_qb_equals_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
27+ return self
28+
29+ def not_equals_string (self , property_id : int , value : str , case_sensitive : bool ):
30+ obx_qb_not_equals_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
31+ return self
32+
33+ def contains_string (self , property_id : int , value : str , case_sensitive : bool ):
34+ obx_qb_contains_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
35+ return self
36+
37+ def starts_with_string (self , property_id : int , value : str , case_sensitive : bool ):
38+ obx_qb_starts_with_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
39+ return self
40+
41+ def ends_with_string (self , property_id : int , value : str , case_sensitive : bool ):
42+ obx_qb_ends_with_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
43+ return self
44+
45+ def greater_than_string (self , property_id : int , value : str , case_sensitive : bool ):
46+ obx_qb_greater_than_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
47+ return self
48+
49+ def greater_or_equal_string (self , property_id : int , value : str , case_sensitive : bool ):
50+ obx_qb_greater_or_equal_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
51+ return self
52+
53+ def less_than_string (self , property_id : int , value : str , case_sensitive : bool ):
54+ obx_qb_less_than_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
55+ return self
56+
57+ def less_or_equal_string (self , property_id : int , value : str , case_sensitive : bool ):
58+ obx_qb_less_or_equal_string (self ._c_builder , property_id , c_str (value ), case_sensitive )
59+ return self
60+
61+ def equals_int (self , property_id : int , value : int ):
62+ obx_qb_equals_int (self ._c_builder , property_id , value )
63+ return self
64+
65+ def not_equals_int (self , property_id : int , value : int ):
66+ obx_qb_not_equals_int (self ._c_builder , property_id , value )
67+ return self
68+
69+ def greater_than_int (self , property_id : int , value : int ):
70+ obx_qb_greater_than_int (self ._c_builder , property_id , value )
71+ return self
72+
73+ def greater_or_equal_int (self , property_id : int , value : int ):
74+ obx_qb_greater_or_equal_int (self ._c_builder , property_id , value )
75+ return self
76+
77+ def less_than_int (self , property_id : int , value : int ):
78+ obx_qb_less_than_int (self ._c_builder , property_id , value )
79+ return self
80+
81+ def less_or_equal_int (self , property_id : int , value : int ):
82+ obx_qb_less_or_equal_int (self ._c_builder , property_id , value )
83+ return self
84+
85+ def between_2ints (self , property_id : int , value_a : int , value_b : int ):
86+ obx_qb_between_2ints (self ._c_builder , property_id , value_a , value_b )
87+ return self
88+
89+ def apply_condition (self ):
90+ self ._condition .apply (self )
91+
92+ def build (self ) -> Query :
93+ self .apply_condition ()
94+ c_query = obx_query (self ._c_builder )
95+ return Query (c_query , self ._box )
0 commit comments