Contains
Contains( path, in )
Contains( path, in )
Contains( path, in )
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.
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
Array of longs or Strings |
A path to a specified field. |
|
Any |
A value of any type. |
Examples
The query below returns true
because the path favorites.foods
exists
in the document provided to the in argument.
curl https://db.fauna.com/ \
-u fnAChGwBcAACAO70ziE0cfROosNJHdgBmJU1PgpL: \
-d '{
"contains": [ "favorites", "foods" ],
"in": {
"object": {
"favorites": {
"object": { "foods": [ "crunchings", "munchings", "lunchings" ] }
}
}
}
}'
client.Query(
Contains(
Arr("favorites", "foods"),
Obj(
"favorites", Obj("foods", Arr("crunchings", "munchings", "lunchings"))
)));
System.out.println(
client.query(
Contains(
Arr(Value("favorites"), Value("foods")),
Obj(
"favorites", Obj(
"foods", Arr(
Value("crunchings"),
Value("munchings"),
Value("lunchings")
)
)
)
)
)
.get());
result, _ := client.Query(
f.Contains(
f.Arr{"favorites", "foods"},
f.Obj{
"favorites": f.Obj{
"foods": f.Arr{"crunchings", "munchings", "lunchings"},
},
},
),
)
fmt.Println(result)
client.query(
Contains(
Arr("favorites", "foods"),
Obj(
"favorites" -> Obj("foods" -> Arr("crunchings", "munchings", "lunchings"))
)))
client.query(
q.contains(
["favorites", "foods"],
{
"favorites": {"foods": ["crunchings", "munchings", "lunchings"]}
}
))
$client.query do
contains ['favorites', 'foods'],
favorites: { foods: ['crunchings', 'munchings', 'lunchings'] }
end
client.query(
Contains(
path: "favorites", "foods",
in: Obj(
"favorites" => Obj(
"foods" => Arr("crunchings", "munchings", "lunchings")
)
)
)
)
client.query(
q.Contains(["favorites", "foods"],
{ favorites: { foods: ["crunchings", "munchings", "lunchings"] } }))
.then((ret) => console.log(ret))
HTTP/1.1 200 OK
{ "resource": true }
true
true
true
true
true
true
true
true
Was this article helpful?
We're sorry to hear that.
Tell us how we can improve!
documentation@fauna.com
Thank you for your feedback!