How i can update value in database using objection ? My SQL query works perfect.
UPDATE "freePlace"
SET number = number-1
WHERE date >= '2017-10-20' AND date <= '2017-10-30' AND "idObject" = '1'
My objection code:
FreePlace.query().patch({number:number+1}).where('date', '>=', startDate)
.andWhere('date', '<=', endDate)
.andWhere('idParking', '=', parkingId)
Problem is in patch({number:number+1}) how i need do this ?
Looks like you need to use ref(). The code as you have it won't know where to get the value of "number+1".
How about this?
See this example from objection.js docs: