Increment field in patch call

I would really like to increment a table field without first GET’ing that value, as there is a change that multiple users could be calling this script at the same time.
So, I am thinking it would be great to have some mark-up in the PATCH call that indicates an increment.
Some mark-up like this may work:
platform.api.patch(“db/tableName”, {“somefield”: “++2” });
It may be tricky because of the filed type should be integer and passing in a string.

Maybe it is already possible, if so, then let me know :smile:
Haven’t looked at stored procedures yet, is that an option??

Lee looked at this and has a good idea on implementing markup operations in PATCH (CAST, CONVERT, formatting, concatenation, math, etc. can be passed in as a value to a field). It may be released in 1.9 coming out next week. I’ll let you know when it ships.

Regarding stored procedures, the docs are here This is a good option.

Hello Ben is there more in-depth example on that increment value by 1 or 2 by patch on mongodb? thanks!

@Rusher I don’t have an example handy, sorry.

Dear ben, is it possible? because I can’t seems to get the field increment by 1 or 2 by patch call

1 Like