Skip to content

Commit

Permalink
#1: Add patch function
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Jun 20, 2019
1 parent e58f162 commit 9b08dc6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions common/database_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,21 @@ def get_first_filtered_row(table, filters):
:return: the first row matching the filter
"""
return get_rows_by_filter(table, filters)[0]


def patch_entities(table, json_list):
"""
Update one or more rows in the given table, from the given list containing json. Each entity must contain its ID
:param table: The table of the entities
:param json_list: the list of updated values
:return: The list of updated rows.
"""
results = []
for entity in json_list:
for key in entity:
if key.upper() == "ID":
update_row_from_id(table, entity[key], entity)
result = get_row_by_id(table, entity[key])
results.append(result)

return results

0 comments on commit 9b08dc6

Please sign in to comment.