offsetsOf

ReQL command: offsetsOf

Command syntax

sequence.offsetsOf(datum | predicate_function) → array

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)

Get more help

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/javascript/offsets_of/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部