set.take()

Get an Set with the first Number of Set values.

Lazy loading:

Yes

Signature

take(count: Number) => Set

Description

The take() method takes the first count values from the Set and returns them in an Set. If there are fewer values than count in the Set, all Set values are returned in the Set.

Parameters

Parameter Type Required Description

count

Number

Yes

Number of values that you want to return from the start of the Set.

Return value

Type Description

Set

Set with the first count values from the given Set.

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!