def update_data_item(cls, pk_id, params): _params = {p: params[p] for p in params if p in DataItem.field_names()} with db: # old_data_item = DataItem.get_by_id(pk=pk_id) DataItem.update(**_params).where(DataItem.id == pk_id).execute() # for f in fields: # if f in params: # setattr(old_data_item, f, params[f]) # print("{}:{}".format(f, params[f])) # old_data_item.save() # print("update data item:", old_data_item) es_up_params = es_dao_local().filter_update_params(_params) if es_up_params: logger.info( "will update es item es_up_params:{}".format(es_up_params)) es_dao_local().update_fields(pk_id, **es_up_params)
def update_data_item_by_parent_id(cls, parent_id, params): _params = {p: params[p] for p in params if p in DataItem.field_names()} with db: # old_data_item = DataItem.get_by_id(pk=pk_id) DataItem.update(**_params).where( DataItem.parent == parent_id).execute()