Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

set.take()

Get the first N elements of a Set.

Loading strategy:

Signature

take(limit: Number) => Set<A>

Description

Takes the first N elements from the calling Set and returns them as a new Set. If there are fewer values than N elements in the Set, all elements are returned.

The calling Set isn’t changed.

Parameters

Parameter Type Required Description

limit

Number

Yes

Number of elements to return from the start of the Set.

Return value

Type Description

Set<Generic>

Set containing the requested elements.

Examples

Get the first two documents in the Set of Product documents:

Product.all().take(2)
{
  data: [
    {
      id: "111",
      coll: Product,
      ts: Time("2099-10-22T21:56:31.260Z"),
      name: "cups",
      description: "Translucent 9 Oz, 100 ct",
      price: 698,
      stock: 100,
      category: Category("123")
    },
    {
      id: "222",
      coll: Product,
      ts: Time("2099-10-22T21:56:31.260Z"),
      name: "donkey pinata",
      description: "Original Classic Donkey Pinata",
      price: 2499,
      stock: 50,
      category: Category("123")
    }
  ]
}

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!