Skip to content

Sum the new setter with the data #69

@thadeubrito

Description

@thadeubrito

Hello, I don't know if is possible do it using this gem, it is the case:

connection = Mysql2::Client.new([...])
Upsert.batch(connection, :pets) do |upsert|
  # N times...
  upsert.row({:name => 'product1'}, :count => 2)
  upsert.row({:name => 'product2'}, :count => 10)
end

I don't wanna only update the count attribute, if the product1 has a count: 1 in the database, I wanna sum the database value with the new value. In this case product1.count became 3(2+1).

Is it possible? Thanks all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions