Method: Flydata::QueryBasedSync::ResponseHandler#handle

Defined in:
lib/flydata/query_based_sync/response_handler.rb

#handle(response) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/flydata/query_based_sync/response_handler.rb', line 13

def handle(response)
  records = response.records.collect{|r| {row: r} }

  emit_sync_records(records,
                    type: :update,  # upsert only
                    src_pos: response.new_source_pos.to_s,
                    table: response.table_name)

  # TODO: Revisit and check if transaction management is needed
  # However, since we use 'upsert' for query based sync,
  # duplicate event will not cause an issue.
  context.table_src_pos_files[response.table_name.to_sym].
    save(response.new_source_pos)
end