Skip to content

Commit

Permalink
remove data as attributes (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncgl-syngenta authored Jan 28, 2022
1 parent ede4fb9 commit 8906031
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions syngenta_digital_dta/dynamodb/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def __init__(self, **kwargs):
self.model_schema = kwargs['model_schema']
self.model_identifier = kwargs['model_identifier']
self.model_version_key = kwargs['model_version_key']
self.data_as_attributes = kwargs.get('data_as_attributes', False)

@lru_cache(maxsize=128)
def _get_dynamo_table(self, table, endpoint=None):
Expand Down Expand Up @@ -56,16 +55,12 @@ def query(self, **kwargs):
def overwrite(self, **kwargs):
overwrite_item = schema_mapper.map_to_schema(kwargs['data'], self.model_schema_file, self.model_schema)
self.table.put_item(Item=overwrite_item)
if self.data_as_attributes:
self.sns_custom = overwrite_item
super().publish('create', overwrite_item)
return overwrite_item

def insert(self, **kwargs):
new_item = schema_mapper.map_to_schema(kwargs['data'], self.model_schema_file, self.model_schema)
self.table.put_item(Item=new_item, ConditionExpression=Attr(self.model_identifier).not_exists())
if self.data_as_attributes:
self.sns_custom = new_item
super().publish('create', new_item)
return new_item

Expand Down Expand Up @@ -104,8 +99,6 @@ def update(self, **kwargs):
updated_data = schema_mapper.map_to_schema(merged_data, self.model_schema_file, self.model_schema)
self.table.put_item(Item=updated_data, ConditionExpression=Attr(
self.model_version_key).eq(original_data[self.model_version_key]))
if self.data_as_attributes:
self.sns_custom = updated_data
super().publish('update', updated_data)
return updated_data

Expand Down

0 comments on commit 8906031

Please sign in to comment.