sequence.coerce_to('array') → array
value.coerce_to('string') → string
string.coerce_to('number') → number
array.coerce_to('object') → object
sequence.coerce_to('object') → object
object.coerce_to('array') → array
binary.coerce_to('string') → string
string.coerce_to('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|
{ :comments => r.table('comments').get_all(post['id'], {:index => 'post_id'}).coerce_to('array') }
}.run(conn)
Example: Coerce an array of pairs into an object.
r.expr([['name', 'Ironman'], ['victories', 2000]]).coerce_to('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).coerce_to('string').run(conn)
Couldn't find what you were looking for?
Contribute: edit this page or open an issue