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. |
ContainsPath
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
ContainsPath(path, in )
contains_path(path, in )
ContainsPath( path, in )
ContainsPath( path, in )
ContainsPath(path, in )
Description
The ContainsPath
function returns true
if the specified path
exists
within the result of the in
expression, or false
otherwise.
ContainsPath
is useful when you need to distinguish between objects,
arrays, or documents that contain a nested path and those that do not.
The path
is an array containing path selectors. Each path selector is
a number (representing an array offset) or a string (representing a field
name). The path is evaluated from left to right, and each path selector
after the first represents a nesting within the data structure of the
result of the in
expression.
For example, if you provide the path 0, a, 1, b
, the result of the
in
expression has to be an array where the first item is an object
with the field a
, whose value is an array and the second item in that
array is an object with the field b
. The minimal structure that would
satisfy that path is:
[
{
"a": [
{},
{ "b": true }
]
}
]
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Array of Numbers and/or Strings |
A path to a specified field or array entry within the |
|
Any |
A value of any type. |
Examples
-
Array offsets
The following query returns
true
because the path1, 2
(targeting the valuec
) exists within the provided array:true
True
true
BooleanV(True)
true
-
Field names
The following query returns
true
because the pathb, two
exists because the provided object has ab
field that contains an object with thetwo
field:true
True
true
BooleanV(True)
true
-
Mixing field names and array offsets
The following query returns
true
because the path2, first
(which refers to the field containingGrace
) exists in the provided array:true
True
true
BooleanV(True)
true
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!