Class: Baza::Driver::Sqlite3::Commands
- Inherits:
-
Object
- Object
- Baza::Driver::Sqlite3::Commands
show all
- Defined in:
- lib/baza/driver/sqlite3/commands.rb
Instance Method Summary
collapse
Constructor Details
#initialize(args) ⇒ Commands
Returns a new instance of Commands.
2
3
4
|
# File 'lib/baza/driver/sqlite3/commands.rb', line 2
def initialize(args)
@db = args.fetch(:db)
end
|
Instance Method Details
#last_id ⇒ Object
25
26
27
|
# File 'lib/baza/driver/sqlite3/commands.rb', line 25
def last_id
@db.query("SELECT last_insert_rowid() AS id").fetch.fetch(:id).to_i
end
|
#upsert(table_name, updates, terms, args = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/baza/driver/sqlite3/commands.rb', line 15
def upsert(table_name, updates, terms, args = {})
Baza::SqlQueries::NonAtomicUpsert.new(
db: @db,
table_name: table_name,
buffer: args[:buffer],
terms: terms,
updates: updates
).execute
end
|
#upsert_duplicate_key(table_name, updates, terms = {}, args = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/baza/driver/sqlite3/commands.rb', line 6
def upsert_duplicate_key(table_name, updates, terms = {}, args = {})
Baza::SqlQueries::SqliteUpsertDuplicateKey.new({
db: @db,
table_name: table_name,
updates: updates,
terms: terms
}.merge(args)).execute
end
|