Reputation: 2029
I am updating some table and I need to check if the update was successful. I am doing this
MyTable.update({ MyTable.name eq "abcd" }) {
it[col1] = "col1 value"
}
In the current state, if I try to update some value that does not exist in DB, even then the call succeeds (probably saying zero rows updated).
How do I know if there was actually a row to be updated or how do I get the number of rows updated?
Upvotes: 1
Views: 2271
Reputation: 2029
It is pretty simple. The output of update
call returns the count.
val numRowsUpdated = MyTable.update({ MyTable.name eq "abcd" }) {
it[col1] = "col1 value"
}
numRowsUpdated
will have the count.
Upvotes: 1