Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (26 sloc) 768 Bytes
layout language permalink command alias io
api-command
JavaScript
api/javascript/offsets_of/
offsetsOf
api/javascript/indexes_of/
sequence
array

Command syntax

{% apibody %} sequence.offsetsOf(datum | predicate_function) → array {% endapibody %}

Description

Get the indexes of an element in a sequence. If the argument is a predicate, get the indexes of all elements matching it.

Example: Find the position of the letter 'c'.

r.expr(['a','b','c']).offsetsOf('c').run(conn, callback)

Example: Find the popularity ranking of invisible heroes.

r.table('marvel').union(r.table('dc')).orderBy('popularity').offsetsOf(
    r.row('superpowers').contains('invisibility')
).run(conn, callback)
You can’t perform that action at this time.