sequence.coerceTo("array") → array value.coerceTo("string") → string string.coerceTo("number") → number array.coerceTo("object") → object sequence.coerceTo("object") → object object.coerceTo("array") → array binary.coerceTo("string") → string string.coerceTo("binary") → binary
Convert a value of one type into another.
Example: Coerce a stream to an array to store its output in a field. (A stream cannot be stored in a field directly.)
r.table("posts").map(post -> post.merge( r.hashMap("comments", r.table("comments").getAll(post.g("id")).optArg("index", "post_id") .coerceTo("array")) )).run(conn);
Example: Coerce an array of key-value pairs into an object.
r.expr(r.array(r.array("name", "Ironman"), r.array("victories", 2000))) .coerceTo("object").run(conn);
Note: To coerce a list of key-value pairs like ["name", "Ironman", "victories", 2000]
to an object, use the object command.
Example: Coerce a number to a string.
r.expr(1).coerceTo("string").run(conn);
Couldn't find what you were looking for?
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/java/coerce_to/