Combining and comparing result sets

Overview

Some types of Fauna queries return one or more groups of results, with the ability to combine and compare those groups in various ways. This page demonstrates several of the Fauna Query Language functions which assist with the combining, comparison, and filtering of query results.

A group may be an Array, a Set, or a Set Reference.

Union

The Union function performs a logical OR operation on two or more groups. It returns a de-duplicated group of all the results.

The following example combines the Set Reference returned by locating the search term fire in the index named spells_by_element and the Set Reference returned by locating the search term water in the same index. In other words, the query finds all spells which have either fire or water in the element field. The Paginate function materializes the results of the Union operation into a Page.

try
{
    Value result = await client.Query(
        Paginate(
            Union(
                Match(Index("spells_by_element"), "fire"),
                Match(Index("spells_by_element"), "water")
            )
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(RefV(id = "181388642046968320", collection = RefV(id = "spells", collection = RefV(id = "collections"))), RefV(id = "181388642071085568", collection = RefV(id = "spells", collection = RefV(id = "collections"))), RefV(id = "181388642088911360", collection = RefV(id = "spells", collection = RefV(id = "collections")))))
result, err := client.Query(
	f.Paginate(
		f.Union(
			f.MatchTerm(f.Index("spells_by_element"), "fire"),
			f.MatchTerm(f.Index("spells_by_element"), "water"))))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[{181388642046968320 0xc000164180 0xc000164180 <nil>} {181388642071085568 0xc000164330 0xc000164330 <nil>} {181388642088911360 0xc0001644e0 0xc0001644e0 <nil>}]]
System.out.println(
    client.query(
        Paginate(
            Union(
                Match(Index("spells_by_element"), Value("fire")),
                Match(Index("spells_by_element"), Value("water"))
            )
        )
    ).get());
{data: [ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections"))), ref(id = "181388642071085568", collection = ref(id = "spells", collection = ref(id = "collections"))), ref(id = "181388642088911360", collection = ref(id = "spells", collection = ref(id = "collections")))]}
client.query(
  q.Paginate(
    q.Union(
      q.Match(q.Index('spells_by_element'), 'fire'),
      q.Match(q.Index('spells_by_element'), 'water'),
    )
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  data: [
    Ref(Collection("spells"), "181388642046968320"),
    Ref(Collection("spells"), "181388642071085568"),
    Ref(Collection("spells"), "181388642088911360")
  ]
}
result = client.query(
  q.paginate(
    q.union(
      q.match(q.index("spells_by_element"), "fire"),
      q.match(q.index("spells_by_element"), "water")
    )
  )
)
print(result)
{'data': [Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections))), Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))), Ref(id=181388642088911360, collection=Ref(id=spells, collection=Ref(id=collections)))]}
Paginate(
  Union(
    Match(Index('spells_by_element'), 'fire'),
    Match(Index('spells_by_element'), 'water'),
  )
)
{
  data: [
    Ref(Collection("spells"), "181388642046968320"),
    Ref(Collection("spells"), "181388642071085568"),
    Ref(Collection("spells"), "181388642088911360")
  ]
}
Query metrics:
  •    bytesIn: 135

  •   bytesOut: 377

  • computeOps:   1

  •    readOps:   2

  •   writeOps:   0

  •  readBytes: 211

  • writeBytes:   0

  •  queryTime: 7ms

  •    retries:   0

For more information and code examples, see the Union reference page.

Intersection

The Intersection function performs a logical AND operation on two or more groups. It returns results which are common to all the groups.

The following example intersects the Set Reference returned by locating the search term fire in the index named spells_by_element with the Set Reference returned by locating the search term water in the same index. In other words, the query finds all spells which have both fire and water in the element field.

try
{
    Value result = await client.Query(
        Intersection(
            Match(Index("spells_by_element"), "water"),
            Match(Index("spells_by_element"), "fire")
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
SetRefV(System.Collections.Generic.Dictionary`2[System.String,FaunaDB.Types.Value])
result, err := client.Query(
	f.Intersection(
		f.MatchTerm(f.Index("spells_by_element"), "water"),
		f.MatchTerm(f.Index("spells_by_element"), "fire")))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
{map[intersection:[{map[match:{spells_by_element 0xc0001500f0 0xc0001500f0 <nil>} terms:water]} {map[match:{spells_by_element 0xc000150210 0xc000150210 <nil>} terms:fire]}]]}
System.out.println(
    client.query(
        Intersection(
            Match(Index("spells_by_element"), Value("fire")),
            Match(Index("spells_by_element"), Value("water"))
        )
    ).get());
{@set = {intersection: [{@set = {match: ref(id = "spells_by_element", collection = ref(id = "indexes")), terms: "fire"}}, {@set = {match: ref(id = "spells_by_element", collection = ref(id = "indexes")), terms: "water"}}]}}
client.query(
  q.Intersection(
    q.Match(q.Index('spells_by_element'), 'water'),
    q.Match(q.Index('spells_by_element'), 'fire'),
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
Intersection(Match(Index("spells_by_element"), "water"), Match(Index("spells_by_element"), "fire"))
result = client.query(
  q.intersection(
    q.match(q.index("spells_by_element"), "water"),
    q.match(q.index("spells_by_element"), "fire")
  )
)
print(result)
SetRef({'intersection': [SetRef({'match': Ref(id=spells_by_element, collection=Ref(id=indexes)), 'terms': 'water'}), SetRef({'match': Ref(id=spells_by_element, collection=Ref(id=indexes)), 'terms': 'fire'})]})
Intersection(
  Match(Index('spells_by_element'), 'water'),
  Match(Index('spells_by_element'), 'fire'),
)
Intersection(Match(Index("spells_by_element"), "water"), Match(Index("spells_by_element"), "fire"))
Query metrics:
  •    bytesIn: 129

  •   bytesOut: 259

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 9ms

  •    retries:   0

For more information and code examples, see the Intersection reference page.

Difference

The Difference function compares two groups and returns those items which are present in the first group but not the second.

The following example takes the Set Reference which is created by locating the search term fire in the index named spells_by_element and removes all documents in the Set Reference which is created by locating the search term fire in the same index. In other words, the query finds all documents which have fire in the element field, then removes all documents which have water in the element field.

try
{
    Value result = await client.Query(
        Paginate(
            Difference(
                Match(Index("spells_by_element"), "fire"),
                Match(Index("spells_by_element"), "water")
            )
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(RefV(id = "181388642046968320", collection = RefV(id = "spells", collection = RefV(id = "collections")))))
result, err := client.Query(
	f.Paginate(
		f.Difference(
			f.MatchTerm(f.Index("spells_by_element"), "fire"),
			f.MatchTerm(f.Index("spells_by_element"), "water"))))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[{181388642046968320 0xc000142270 0xc000142270 <nil>}]]
System.out.println(
    client.query(
        Paginate(
            Difference(
                Match(Index("spells_by_element"), Value("fire")),
                Match(Index("spells_by_element"), Value("water"))
            )
        )
    ).get());
{data: [ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections")))]}
client.query(
  q.Paginate(
    q.Difference(
      q.Match(q.Index('spells_by_element'), 'fire'),
      q.Match(q.Index('spells_by_element'), 'water'),
    )
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data: [ Ref(Collection("spells"), "181388642046968320") ] }
result = client.query(
  q.paginate(
    q.difference(
      q.match(q.index("spells_by_element"), "fire"),
      q.match(q.index("spells_by_element"), "water")
    )
  )
)
print(result)
{'data': [Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections)))]}
Paginate(
  Difference(
    Match(Index('spells_by_element'), 'fire'),
    Match(Index('spells_by_element'), 'water'),
  )
)
{ data: [ Ref(Collection("spells"), "181388642046968320") ] }
Query metrics:
  •    bytesIn:  140

  •   bytesOut:  141

  • computeOps:    1

  •    readOps:    2

  •   writeOps:    0

  •  readBytes:  211

  • writeBytes:    0

  •  queryTime: 11ms

  •    retries:    0

For more information and code examples, see the Difference reference page.

Join

The Join function joins the items in one group with the items in the second. The items may be filtered, depending on the type of groups being joined.

The following example performs a Join operation on two sets of documents. The first set is the result of a Match operation, which searches the index spellbooks_by_owner for a particular character which is specified by ID. The second set is the documents contained in an index called spells_by_spellbook. In effect, this query answers the question "What spells can this character cast?"

try
{
    Value result = await client.Query(
        Map(
            Paginate(
                Join(
                    Match(
                        Index("spellbooks_by_owner"),
                        Ref(Collection("characters"), "181388642114077184")
                    ),
                    Index("spells_by_spellbook")
                )
            ),
            Lambda("ref", Get(Var("ref")))
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(ObjectV(ref: RefV(id = "181388642046968320", collection = RefV(id = "spells", collection = RefV(id = "collections"))),ts: LongV(1626225336060000),data: ObjectV(name: StringV(Fire Beak),element: Arr(StringV(air), StringV(fire)),spellbook: RefV(id = "181388642139243008", collection = RefV(id = "spellbooks", collection = RefV(id = "collections"))))), ObjectV(ref: RefV(id = "181388642071085568", collection = RefV(id = "spells", collection = RefV(id = "collections"))),ts: LongV(1626225336060000),data: ObjectV(name: StringV(Water Dragon's Claw),element: Arr(StringV(water), StringV(fire)),spellbook: RefV(id = "181388642139243008", collection = RefV(id = "spellbooks", collection = RefV(id = "collections")))))))
result, err := client.Query(
	f.Map(
		f.Paginate(
			f.Join(
				f.MatchTerm(
					f.Index("spellbooks_by_owner"),
					f.Ref(f.Collection("characters"), "181388642114077184")),
				f.Index("spells_by_spellbook"),
			),
		),
		f.Lambda("ref", f.Get(f.Var("ref"))),
	))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[map[data:map[element:[air fire] name:Fire Beak spellbook:{181388642139243008 0xc000092780 0xc000092780 <nil>}] ref:{181388642046968320 0xc0000925a0 0xc0000925a0 <nil>} ts:1626225336060000] map[data:map[element:[water fire] name:Water Dragon's Claw spellbook:{181388642139243008 0xc000092b40 0xc000092b40 <nil>}] ref:{181388642071085568 0xc000092960 0xc000092960 <nil>} ts:1626225336060000]]]
System.out.println(
    client.query(
        Map(
            Paginate(
                Join(
                    Match(
                        Index("spellbooks_by_owner"),
                        Ref(Collection("characters"), "181388642114077184")
                    ),
                    Index("spells_by_spellbook")
                )
            ),
            Lambda("ref", Get(Var("ref")))
        )
    ).get());
{data: [{ref: ref(id = "181388642046968320", collection = ref(id = "spells", collection = ref(id = "collections"))), ts: 1626225336060000, data: {name: "Fire Beak", element: ["air", "fire"], spellbook: ref(id = "181388642139243008", collection = ref(id = "spellbooks", collection = ref(id = "collections")))}}, {ref: ref(id = "181388642071085568", collection = ref(id = "spells", collection = ref(id = "collections"))), ts: 1626225336060000, data: {name: "Water Dragon's Claw", element: ["water", "fire"], spellbook: ref(id = "181388642139243008", collection = ref(id = "spellbooks", collection = ref(id = "collections")))}}]}
client.query(
  q.Map(
    q.Paginate(
      q.Join(
        q.Match(
          q.Index('spellbooks_by_owner'),
          q.Ref(q.Collection('characters'), '181388642114077184')
        ),
        q.Index('spells_by_spellbook'),
      )
    ),
    q.Lambda('ref', q.Get(q.Var('ref')))
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  data: [
    {
      ref: Ref(Collection("spells"), "181388642046968320"),
      ts: 1632781965880000,
      data: {
        name: 'Fire Beak',
        element: [ 'air', 'fire' ],
        spellbook: Ref(Collection("spellbooks"), "181388642139243008")
      }
    },
    {
      ref: Ref(Collection("spells"), "181388642071085568"),
      ts: 1632781965880000,
      data: {
        name: "Water Dragon's Claw",
        element: [ 'water', 'fire' ],
        spellbook: Ref(Collection("spellbooks"), "181388642139243008")
      }
    }
  ]
}
result = client.query(
  q.map_(
    q.lambda_("ref", q.get(q.var("ref"))),
    q.paginate(
      q.join(
        q.match(
          q.index("spellbooks_by_owner"),
          q.ref(q.collection("characters"), "181388642114077184")
        ),
        q.index("spells_by_spellbook")
      )
    )
  )
)
print(result)
{'data': [{'ref': Ref(id=181388642046968320, collection=Ref(id=spells, collection=Ref(id=collections))), 'ts': 1626225336060000, 'data': {'name': 'Fire Beak', 'element': ['air', 'fire'], 'spellbook': Ref(id=181388642139243008, collection=Ref(id=spellbooks, collection=Ref(id=collections)))}}, {'ref': Ref(id=181388642071085568, collection=Ref(id=spells, collection=Ref(id=collections))), 'ts': 1626225336060000, 'data': {'name': "Water Dragon's Claw", 'element': ['water', 'fire'], 'spellbook': Ref(id=181388642139243008, collection=Ref(id=spellbooks, collection=Ref(id=collections)))}}]}
Map(
  Paginate(
    Join(
      Match(
        Index('spellbooks_by_owner'),
        Ref(Collection('characters'), '181388642114077184')
      ),
      Index('spells_by_spellbook'),
    )
  ),
  Lambda("ref", Get(Var("ref")))
)
{
  data: [
    {
      ref: Ref(Collection("spells"), "181388642046968320"),
      ts: 1626225336060000,
      data: {
        name: 'Fire Beak',
        element: [ 'air', 'fire' ],
        spellbook: Ref(Collection("spellbooks"), "181388642139243008")
      }
    },
    {
      ref: Ref(Collection("spells"), "181388642071085568"),
      ts: 1626225336060000,
      data: {
        name: "Water Dragon's Claw",
        element: [ 'water', 'fire' ],
        spellbook: Ref(Collection("spellbooks"), "181388642139243008")
      }
    }
  ]
}
Query metrics:
  •    bytesIn:  239

  •   bytesOut:  705

  • computeOps:    1

  •    readOps:    3

  •   writeOps:    0

  •  readBytes:  418

  • writeBytes:    0

  •  queryTime: 18ms

  •    retries:    0

For more information and code examples, see the Join reference page.

Filter

The Filter function takes as arguments a set, array, or page of items and a Lambda function. The Lambda function must return a Boolean, and Filter returns all items from the group for which the Lambda evaluates to true.

The following example takes the contents of the index people_by_age_first and a lambda function which looks for names which start with letters between A and M. It returns the documents from the index for which the lambda function returns true.

The C# version of this example is not currently available.
The Go version of this example is not currently available.
The Java version of this example is not currently available.
client.query(
  q.Paginate(
    q.Filter(
      q.Match(q.Index('people_by_age_first')),
      q.Lambda(
        ['age', 'name'],
        q.And(
          q.GTE(q.Var('name'), 'A'),
          q.LTE(q.Var('name'), 'M'),
        )
      )
    )
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  data: [
    [ 80, 'Leslie' ],
    [ 97, 'Alan' ],
    [ 107, 'Alan' ],
    [ 119, 'Grace' ]
  ]
}
The Python version of this example is not currently available.
The Shell version of this example is not currently available.
Query metrics:
  •    bytesIn:  190

  •   bytesOut:   76

  • computeOps:    1

  •    readOps:    8

  •   writeOps:    0

  •  readBytes:  486

  • writeBytes:    0

  •  queryTime: 51ms

  •    retries:    0

The above example uses Paginate to materialize the query results into a Page. It is, however, possible to use Paginate on the results of the Match query to limit the number of documents to pass on to the lambda function, as shown in the following example:

The C# version of this example is not currently available.
The Go version of this example is not currently available.
The Java version of this example is not currently available.
client.query(
  q.Filter(
    q.Paginate(
      q.Match(q.Index('people_by_age_first')),
      { size: 4 }
    ),
    q.Lambda(
      ['age', 'name'],
      q.And(
        q.GTE(q.Var('name'), 'A'),
        q.LTE(q.Var('name'), 'M'),
      )
    )
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{
  after: [ 97, 'Alan', Ref(Collection("People"), "326502729981624832") ],
  data: [ [ 80, 'Leslie' ] ]
}
The Python version of this example is not currently available.
The Shell version of this example is not currently available.
Query metrics:
  •    bytesIn:  199

  •   bytesOut:  175

  • computeOps:    1

  •    readOps:    8

  •   writeOps:    0

  •  readBytes:  486

  • writeBytes:    0

  •  queryTime: 14ms

  •    retries:    0

In the above example, the Paginate function takes a size parameter of 4, so only the first 4 documents in the index are passed on to the lambda function, and we learn that in the first 4 documents of the index only one name starts with a letter between A and M.

For more information and code examples, see the Filter reference page.

Range

The Range function takes three parameters: a set, a start value, and an end value. It returns an inclusive subset of the values from the provided set that includes the range of values starting from start up to (and including) end, as defined by the order of the set.

The following example uses a collection containing the letters of the alphabet and an index with a values field defined to contain each document’s letter field. See the indexing tutorials for the query that creates these documents. The following query returns the range of values from F to M:

try
{
    Value result = await client.Query(
        Paginate(
            Range(Match(Index("letters")), "F", "M")
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(StringV(F), StringV(G), StringV(H), StringV(I), StringV(J), StringV(K), StringV(L), StringV(M)))
result, err := client.Query(
	f.Paginate(
		f.Range(
			f.Match(
				f.Index("letters")),
				"F", "M")))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[F G H I J K L M]]
System.out.println(
    client.query(
        Paginate(
            Range(Match(Index("letters")), Value("F"), Value("M"))
        )
    ).get());
{data: ["F", "G", "H", "I", "J", "K", "L", "M"]}
client.query(
  q.Paginate(
    q.Range(q.Match(q.Index('letters')), 'F', 'M')
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data: [ 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M' ] }
result = client.query(
  q.paginate(
    q.range(q.match(q.index("letters")), "F", "M")
  )
)
print(result)
{'data': ['F', 'G', 'H', 'I', 'J', 'K', 'L', 'M']}
Paginate(
  Range(Match(Index('letters')), 'F', 'M')
)
{ data: [
    'F', 'G', 'H',
    'I', 'J', 'K',
    'L', 'M'
  ] }
Query metrics:
  •    bytesIn:   83

  •   bytesOut:   55

  • computeOps:    1

  •    readOps:    8

  •   writeOps:    0

  •  readBytes:  488

  • writeBytes:    0

  •  queryTime: 13ms

  •    retries:    0

You can also use Range to return all values up to and including the end parameter, or all values including and after the start value, by providing an empty array for either the start or end value.

The following example returns all letters up to and including 'M':

try
{
    Value result = await client.Query(
        Paginate(
            Range(Match(Index("letters")), Arr(), "M")
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(StringV(A), StringV(B), StringV(C), StringV(D), StringV(E), StringV(F), StringV(G), StringV(H), StringV(I), StringV(J), StringV(K), StringV(L), StringV(M)))
result, err := client.Query(
	f.Paginate(
		f.Range(
			f.Match(f.Index("letters")), f.Arr{}, "M")))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[A B C D E F G H I J K L M]]
System.out.println(
    client.query(
        Paginate(
            Range(Match(Index("letters")), Arr(), Value("M"))
        )
    ).get());
{data: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"]}
client.query(
  q.Paginate(
    q.Range(q.Match(q.Index('letters')), [], 'M')
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data:
   [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M' ] }
result = client.query(
  q.paginate(
    q.range(q.match(q.index("letters")), [], "M")
  )
)
print(result)
{'data': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M']}
Paginate(
  Range(Match(Index('letters')), [], 'M')
)
{
  data: [
    'A', 'B', 'C', 'D',
    'E', 'F', 'G', 'H',
    'I', 'J', 'K', 'L',
    'M'
  ]
}
Query metrics:
  •    bytesIn:   82

  •   bytesOut:   75

  • computeOps:    1

  •    readOps:    8

  •   writeOps:    0

  •  readBytes:  708

  • writeBytes:    0

  •  queryTime: 14ms

  •    retries:    0

The following example returns all letters after and including 'F':

try
{
    Value result = await client.Query(
        Paginate(
            Range(Match(Index("letters")), "F", Arr())
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ObjectV(data: Arr(StringV(F), StringV(G), StringV(H), StringV(I), StringV(J), StringV(K), StringV(L), StringV(M), StringV(N), StringV(O), StringV(P), StringV(Q), StringV(R), StringV(S), StringV(T), StringV(U), StringV(V), StringV(W), StringV(X), StringV(Y), StringV(Z)))
result, err := client.Query(
	f.Paginate(
		f.Range(
			f.Match(
				f.Index("letters")),
				"F", f.Arr{})))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
map[data:[F G H I J K L M N O P Q R S T U V W X Y Z]]
System.out.println(
    client.query(
        Paginate(
            Range(Match(Index("letters")), Value("F"), Arr())
        )
    ).get());
{data: ["F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]}
client.query(
  q.Paginate(
    q.Range(q.Match(q.Index('letters')), 'F', [])
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
{ data:
   [ 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
     'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ] }
result = client.query(
  q.paginate(
    q.range(q.match(q.index("letters")), "F", [])
  )
)
print(result)
{'data': ['F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']}
Paginate(
  Range(Match(Index('letters')), 'F', [])
)
{
  data: [
    'F', 'G', 'H', 'I', 'J',
    'K', 'L', 'M', 'N', 'O',
    'P', 'Q', 'R', 'S', 'T',
    'U', 'V', 'W', 'X', 'Y',
    'Z'
  ]
}
Query metrics:
  •    bytesIn:    82

  •   bytesOut:   107

  • computeOps:     1

  •    readOps:     8

  •   writeOps:     0

  •  readBytes: 1,060

  • writeBytes:     0

  •  queryTime:  14ms

  •    retries:     0

For more information and code examples, see the Range reference page.

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!