just wanted to ask, how do i update a value in my mysql DB + 1 using bookshelf.js?
as example:
Update table set value = value +1 where x = y ... ;
solved the problem: await table.query().where('id', id).increment('value', value)
new Model().query().transacting(t).where('id', id).increment('value', value), and bookshelf will auto commit or rollback on Promise resolving or failing.
await Wallet.forge(row).save({balance: balance + 1}, {patch:true})i just dont know how to tell bookshelf to update it with +1. yeah i can retrieve the balance before that with a select query, but since its async it could happen that it selects the same value twice for the same user if he clicks twice before updating it. thats why i want it into one query. this doesnt work because balance is not defined, using 'balance + 1' as a string also doesnt work hereawait table.query().where('id', id).decrement('value', value).decrement()does the exact opposite of what you want. You should use.increment()instead.