@@ -99,27 +99,6 @@ def query_by(
99
99
self ._secondary_index = secondary_index
100
100
return self .find_by (key , comparator , key_value )
101
101
102
- """
103
- Args:
104
- key (str): The table key to filter on.
105
- key_value: The value to use on the filter.
106
-
107
- Returns:
108
- self: The DynoLayer.
109
- or_query_by('likes', '<', 20)
110
- """
111
-
112
- def or_query_by (
113
- self ,
114
- key : str ,
115
- comparator : Literal ["=" , "<" , "<=" , ">" , ">=" , "BETWEEN" , "begins_with" ],
116
- key_value ,
117
- secondary_index = None
118
- ):
119
- self ._is_query_operation = True
120
- self ._secondary_index = secondary_index
121
- return self .or_find_by (key , comparator , key_value )
122
-
123
102
"""
124
103
Args:
125
104
filter_expression (str): The filter expression string.
@@ -211,58 +190,6 @@ def find_by(
211
190
212
191
return self
213
192
214
- """
215
- Args:
216
- attribute (str): The table attribute to filter on.
217
- attribute_value: The value to use on the filter.
218
-
219
- Returns:
220
- self: The DynoLayer.
221
- """
222
-
223
- def or_find_by (
224
- self ,
225
- attribute : str ,
226
- comparator : Literal ["=" , "<" , "<=" , ">" , ">=" , "BETWEEN" , "begins_with" ],
227
- attribute_value
228
- ):
229
- use_or_operator = ' OR '
230
- old_att = ''
231
- if self ._is_find_by :
232
- if str (self ._filter_params .get (f':{ attribute } ' , '' )):
233
- letters = string .ascii_lowercase
234
- random_str = ''
235
- for i in range (4 ):
236
- random_str += random .choice (letters )
237
- old_att = attribute
238
- attribute = random_str + attribute
239
-
240
- if not self ._is_find_by :
241
- self ._is_find_by = True
242
-
243
- if isinstance (attribute_value , dict ) or (isinstance (attribute_value , list ) and comparator != 'BETWEEN' ):
244
- attribute_value = json .dumps (attribute_value )
245
-
246
- filter_param = {
247
- f':{ attribute } ' : attribute_value
248
- }
249
- if comparator == 'BETWEEN' :
250
- self ._filter_expression += f'{ use_or_operator } (#{ attribute } { comparator } :{ attribute [0 ]} AND :{ attribute [1 ]} )'
251
- filter_param = {
252
- f':{ attribute [0 ]} ' : attribute_value [0 ],
253
- f':{ attribute [1 ]} ' : attribute_value [1 ]
254
- }
255
- elif comparator == 'begins_with' :
256
- self ._filter_expression += f'{ use_or_operator } ({ comparator } (#{ attribute } ,:{ attribute } ))'
257
- else :
258
- self ._filter_expression += f'{ use_or_operator } (#{ attribute } { comparator } :{ attribute } )'
259
- self ._filter_params .update (filter_param )
260
- self ._filter_params_name .update ({
261
- f'#{ attribute } ' : old_att if old_att else attribute
262
- })
263
-
264
- return self
265
-
266
193
"""
267
194
This function create a FilterExpression for a query operation
268
195
Args:
@@ -508,7 +435,7 @@ def save(self) -> bool:
508
435
self ._table .put_item (
509
436
Item = data
510
437
)
511
- self ._data ['id' ] = data [self ._partition_key ]
438
+ self ._data [self . _partition_key ] = data [self ._partition_key ]
512
439
return True
513
440
except Exception as e :
514
441
self ._error = str (e )
@@ -556,7 +483,7 @@ def _safe(self):
556
483
zone = os .environ .get ('TIMESTAMP_TIMEZONE' , 'America/Sao_Paulo' )
557
484
timezone = pytz .timezone (zone )
558
485
current_date = datetime .now (timezone )
559
- if not self ._data .get (self . _partition_key ):
486
+ if not self ._data .get ('created_at' , None ):
560
487
self ._data ['created_at' ] = int (current_date .timestamp ())
561
488
self ._data ['updated_at' ] = int (current_date .timestamp ())
562
489
0 commit comments