FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, review the migration guide. Contact support@fauna.com with any questions.

Contains

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

Contains( path, in )
contains( path, in )
Contains( path, in )
Contains( path, in )
Contains( path, in )

Description

The Contains function returns true if the argument passed as in contains a value at the specified path, and false otherwise.

This function is deprecated. You should use its alias ContainsPath instead, or the related ContainsField and ContainsValue functions.

Parameters

Parameter Type Definition and Requirements

path

Array of Numbers and/or Strings

A path to a specified field or array entry within the in value.

in

Any

A value of any type.

Returns

A boolean value.

Examples

The following query returns true because the path favorites.foods exists in the provided object:

client.query(
  q.Contains(
    ['favorites', 'foods'],
    {
      favorites: {
        foods: ['crunchings', 'munchings', 'lunchings'],
      },
    },
  )
)
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
true
result = client.query(
  q.contains(
    ["favorites", "foods"],
    {
      "favorites": {
        "foods": ["crunchings", "munchings", "lunchings"]
      }
    }
  )
)
print(result)
True
result, err := client.Query(
	f.Contains(
		f.Arr{"favorites", "foods"},
		f.Obj{
			"favorites": f.Obj{
				"foods": f.Arr{"crunchings", "munchings", "lunchings"}}}))

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
true
try
{
    Value result = await client.Query(
        Contains(
            Arr("favorites", "foods"),
            Obj(
                "favorites", Obj(
                    "foods", Arr(
                        "crunchings", "munchings", "lunchings"
                    )
                )
            )
        )
    );
    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
BooleanV(True)
Contains(
  ['favorites', 'foods'],
  {
    favorites: {
      foods: ['crunchings', 'munchings', 'lunchings'],
    },
  },
)
true
Query metrics:
  •    bytesIn: 124

  •   bytesOut:  17

  • computeOps:   1

  •    readOps:   0

  •   writeOps:   0

  •  readBytes:   0

  • writeBytes:   0

  •  queryTime: 4ms

  •    retries:   0

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!