all()

Get the set of all documents in the collection.

Signature

all(): Set<Document>

all(range: {from: Any, to: Any}): Set<Document>

Description

The collection object .all() method returns the set of all documents in the collection for the given range.

If all() is the last expression in a query, the first page of the Set is returned.

Parameters

Parameter Type Required Description

range

Object

Object describing the range. Returns all members of the set greater than or equal to from and less than or equal to to, including duplicates for an unordered set. If range is omitted, the method returns all collection objects.

Ranges for documents are accepted only by document ID, such that myDocument.all( {from: myDocument.byid(123)} ) returns all documents beginning with and including document ID 123.

range fields

Name Type Required Description

from

Any

Beginning of range.

to

Any

End of range.

Return value

Type Description

Set<Document>

All documents in the collection in the given range.

Examples

  1. First, get all documents in the collection instance:

    Store.all()
    {
      data: [
        {
          id: "394798953506275394",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "DC Fruits",
          ...
        },
        {
          id: "394798953507323970",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Party Supplies",
          ...
        },
        {
          id: "394798953509421122",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Foggy Bottom Market",
          ...
        }
      ]
    }
  2. Use a range parameter to get all documents beginning with a given document ID:

    Store.all({from: Store.byId("394798953507323970")})
    {
      data: [
        {
          id: "394798953507323970",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Party Supplies",
          ...
        },
        {
          id: "394798953509421122",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Foggy Bottom Market",
          ...
        }
      ]
    }
  3. Get all documents beginning up to a given document ID:

    Store.all({to: Store.byId("394798953507323970")})
    {
      data: [
        {
          id: "394798953506275394",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "DC Fruits",
          ...
        },
        {
          id: "394798953507323970",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Party Supplies",
          ...
        }
      ]
    }
  4. Get all documents between the given from and to range parameters, inclusive:

    Store.all({from: Store.byId("394798953507323970"),
                 to: Store.byId("394798953509421122")})
    {
      data: [
        {
          id: "394798953507323970",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Party Supplies",
          ...
        },
        {
          id: "394798953509421122",
          coll: Store,
          ts: Time("2099-04-10T17:01:12.200Z"),
          name: "Foggy Bottom Market",
          ...
        }
      ]
    }

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!