Documentation Home
X DevAPI User Guide
Download this Manual

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

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('true').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('true').set("counter", "counter + 1").execute()

User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
Sign Up Login You must be logged in to post a comment.