Class: Upsert
- Inherits:
-
Object
- Object
- Upsert
- Defined in:
- lib/upsert.rb,
lib/upsert/row.rb,
lib/upsert/binary.rb,
lib/upsert/buffer.rb,
lib/upsert/quoter.rb,
lib/upsert/version.rb,
lib/upsert/buffer/mysql2_client.rb,
lib/upsert/buffer/pg_connection.rb,
lib/upsert/buffer/sqlite3_database.rb,
lib/upsert/buffer/pg_connection/column_definition.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(connection, table_name) ⇒ Upsert
constructor
A new instance of Upsert.
-
#row(selector, document) ⇒ nil
Upsert a row given a selector and a document.
Constructor Details
#initialize(connection, table_name) ⇒ Upsert
Returns a new instance of Upsert.
51 52 53 |
# File 'lib/upsert.rb', line 51 def initialize(connection, table_name) @buffer = Buffer.for connection, table_name end |
Class Method Details
.stream(connection, table_name) {|Upsert| ... } ⇒ nil
Note:
Buffered in memory until it’s efficient to send to the server a packet.
34 35 36 37 38 39 |
# File 'lib/upsert.rb', line 34 def stream(connection, table_name) upsert = new connection, table_name upsert.buffer.async! yield upsert upsert.buffer.sync! end |
Instance Method Details
#row(selector, document) ⇒ nil
Upsert a row given a selector and a document.
70 71 72 73 |
# File 'lib/upsert.rb', line 70 def row(selector, document) buffer.add selector, document nil end |