ContainsValue
ContainsValue( value, in )
Description
The ContainsValue
function returns true
if the specified value
exists within the result of the in
expression, or false
otherwise.
ContainsValue
is useful when you need to distinguish between object,
arrays, or documents that contain a value (regardless of field name) and
those that do not.
ContainsValue
does not evaluate nested arrays or objects. If you need
to determine whether a value exists within a complex structure, the
Select
function can be used to
target the appropriate section within a structure.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
Any |
A value of any type. |
|
Any |
A value of any type. |
Examples
The following query returns true
because the value 3
exists
in the provided object:
client.query(
q.ContainsValue(
3,
{
'a': 1,
'b': 2,
'c': 3
},
)
)
.then((ret) => console.log(ret))
.catch((err) => console.log('Error:', err))
true
The following query returns false
because the value 7
does not exist
in the provided object:
client.query(
q.ContainsValue(
7,
{
'a': 1,
'b': 2,
'c': 3
},
)
)
.then((ret) => console.log(ret))
.catch((err) => console.log('Error:', err))
false
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!