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:

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)
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
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
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!