Documentation Home
X DevAPI User Guide
Download this Manual

X DevAPI User Guide  /  ...  /  Value Expression Strings

Pre-General Availability Draft: 2017-08-18

10.1.2 Value Expression Strings

Value expression strings are used to compute a value which can then be assigned to a given field or column. This is necessary for both modify() and update(), as well as computing values in documents at insertion time.

An example use of a value expression string would be to increment a counter. The expr() function is used to wrap strings where they would otherwise be interpreted literally. For example, to increment a counter:

// the expression is evaluated on the server
collection.modify().set("counter", expr("counter + 1")).execute()

If you do not wrap the string with expr(), it would be assigning the literal string "counter + 1" to the "counter" member:

// equivalent to directly assigning a string: counter = "counter + 1"
collection.modify().set("counter", "counter + 1").execute()

User Comments
Sign Up Login You must be logged in to post a comment.