concat()

Create an Set by concatenating two Sets.

Lazy loading:

Yes

Signature

concat(otherSet: Set): Set

Description

The concat() method creates an Set by copying the calling set to a new set and appending otherSet.

the calling set and otherSet aren’t changed.

Parameters

Parameter Type Required Description

otherSet

Set

Yes

Set to append to the calling set.

Return value

Type Description

Set

New Set composed of otherSet appended to the calling Set.

Examples

This example concatenates two sets:

  1. List the first set:

    Store.all()
    {
      data: [
        {
          id: "386968888557961284",
          coll: Store,
          ts: Time("2024-01-15T06:45:40.390Z"),
          name: "DC Fruits",
          address: {
            street: "13 Pierstorff Drive",
            city: "Washington",
            state: "DC",
            zipCode: "20220"
          }
        },
        {
          id: "386968888560058436",
          coll: Store,
          ts: Time("2024-01-15T06:45:40.390Z"),
          name: "Foggy Bottom Market",
          address: {
            street: "4 Florida Ave",
            city: "Washington",
            state: "DC",
            zipCode: "20037"
          }
        }
      ]
    }
  2. List the second set:

    Manager.all()
    {
      data: [
        {
          id: "386968888587321412",
          coll: Manager,
          ts: Time("2024-01-15T06:45:40.390Z"),
          firstName: "John",
          lastName: "Bender",
          address: {
            street: "2300 Shermer Road",
            city: "Shermer",
            state: "IL",
            zipCode: "60062"
          },
          telephone: "847-576-5711"
        }
      ]
    }
  3. Concatenate the two sets:

    Store.all()!.concat(Manager.all())
    {
      data: [
        {
          id: "386968888557961284",
          coll: Store,
          ts: Time("2024-01-15T06:45:40.390Z"),
          name: "DC Fruits",
          address: {
            street: "13 Pierstorff Drive",
            city: "Washington",
            state: "DC",
            zipCode: "20220"
          }
        },
        {
          id: "386968888560058436",
          coll: Store,
          ts: Time("2024-01-15T06:45:40.390Z"),
          name: "Foggy Bottom Market",
          address: {
            street: "4 Florida Ave",
            city: "Washington",
            state: "DC",
            zipCode: "20037"
          }
        },
        {
          id: "386968888587321412",
          coll: Manager,
          ts: Time("2024-01-15T06:45:40.390Z"),
          firstName: "John",
          lastName: "Bender",
          address: {
            street: "2300 Shermer Road",
            city: "Shermer",
            state: "IL",
            zipCode: "60062"
          },
          telephone: "847-576-5711"
        }
      ]
    }

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!