Range

Not available in this language yet.
Not available in this language yet.
Range( set, from, to )
Range( set, from, to )
Not available in this language yet.
Not available in this language yet.
Range( set, from, to )
Not available in this language yet.

Description

The Range function returns a subset of the values from the provided set that includes the range of values starting from from up to to, as defined by the order of the set.

Items in a set can be single, scalar values, or can be tuples containing a variety of values of different types. from and to need to match the structure provided by the set, or Range returns an empty set.

Parameters

Argument Type Definition and Requirements

set

Set

The set

from

Value, or Array of values

The value(s) marking the start of the range to return. from is inclusive.

to

Value, or Array of values

The value(s) marking the end of the range to return. to is inclusive.

Returns

A new set containing values from set in the range between from and to inclusive.

Examples

With a collection containing the letters of the alphabet, and an index with a values field defined to contain each document’s letter field, the following query returns the range of values from F to M:

Not available in this language yet.
Not available in this language yet.
System.out.println(
    client.query(
        Paginate(
            Range(Match(Index("letters")), Value("F"), Value("M"))
        )
    ).get());
client.query(
  q.Paginate(
    q.Range(q.Match(q.Index("letters")), "F", "M")
  )
)
.then(ret => console.log(ret))
Not available in this language yet.
Not available in this language yet.
println(Await.result(
  client.query(
    Paginate(
      Range(Match(Index("letters")), "F", "M")
    )
  ),
  5.seconds
))
Not available in this language yet.
{data: ["F", "G", "H", "I", "J", "K", "L", "M"]}
{ data: [ 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M' ] }
{data: ["F", "G", "H", "I", "J", "K", "L", "M"]}
The schema setup is not documented here. Most of what you need to make this example work is included in the Index tutorials, including the creation of the collection and the creation of the letters documents. You would need to create an appropriate index.

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!