Class: CouchdbToSql::TableDeletedMarker
- Inherits:
-
TableBuilder
- Object
- TableOperator
- TableBuilder
- CouchdbToSql::TableDeletedMarker
- Defined in:
- lib/couchdb_to_sql/table_deleted_marker.rb
Overview
Table definition handler for handling database UPSERT operations.
Instance Attribute Summary
Attributes inherited from TableBuilder
Attributes inherited from TableOperator
#parent, #primary_key, #table_name
Instance Method Summary collapse
Methods inherited from TableBuilder
#column, #database, #document, #id, #initialize
Methods inherited from TableOperator
#deduce_primary_key, #handler, #initialize
Constructor Details
This class inherits a constructor from CouchdbToSql::TableBuilder
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/couchdb_to_sql/table_deleted_marker.rb', line 10 def execute dataset = handler.database[table_name] handler.changes.log_info "Deletion with additional info present (#{primary_key} '#{handler.id}'), assuming tombstone. " \ 'Updating data in SQL/Postgres database with data from CouchDB document.' fields = attributes.merge( _deleted: true, _deleted_timestamp: Sequel::CURRENT_TIMESTAMP, rev: handler.rev ) dataset .insert_conflict( target: primary_key, update: fields ) .insert(fields) end |
#key_filter ⇒ Object
28 29 30 31 32 |
# File 'lib/couchdb_to_sql/table_deleted_marker.rb', line 28 def key_filter { primary_key => handler.id } end |