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(function (post) {
return post.merge({ comments: r.table('comments').getAll(post('id'), {index: 'postId'}).coerceTo('array')});
}).run(conn, callback)
Example: Coerce an array of key-value pairs into an object.
r.expr([['name', 'Ironman'], ['victories', 2000]]).coerceTo('object').run(conn, callback)
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, callback)
Couldn't find what you were looking for?
Contribute: edit this page or open an issue