Method: increment
data.posts.increment('votes') // Increment by 1
data.posts.where('id', 10).increment('votes', 13) // Increment by 13
@mkucharz should I also add alias inc?
data.posts.inc('votes')
data.posts.increment('votes')
@Idered I think we can stay with just increment for now, for the better code readability :)
@23doors
Sending PATCH request to this url with {"field_name": {"_increment": 1}} works fine
https://api.syncano.rocks/v2/instances/late-hill-3922/classes/posts/objects/:object_id/
Would it be possible to handle increment for multiple objects?
https://api.syncano.rocks/v2/instances/late-hill-3922/classes/posts/objects/
@Idered you mean update multiple objects? If so - nope. 1 request updates only 1 object.
Ok, then I'll implement:
- Using _increment property
data.posts.increment(100, 'views', 1) // Post id, column, value
- First fetch all objects, then update value with batch query. NOT efficient at all but still, some users might find it useful.
data.posts.where('id', 'in', [10, 100]).increment('views')
@23doors It's not very important feature but in future please think about implementing this in platform.
It’s the same as with any update in REST - they are meant to update 1 object at a time. But if you update by id - you can update without fetching (but still 1 request per object)
@Idered let's for now just implement basic version of single object, we will think later about some batch operations and how to solve it