I have a document like this:
{ "baths": 2, "beds": 3, "id": "3225C", "addrs": [
{
"line2": "",
"line3": "",
"state": "OH",
"zip": "67845",
"line1": "3225 ABC AVE",
"city": "CLEVELAND"
},
{
"line2": "",
"line3": "",
"state": "FL",
"zip": "32818",
"line1": "2438 DEF AVE",
"city": "ORLANDO"
} ], "homeAddress": {
"line2": "",
"line3": "",
"state": "FL",
"zip": "32818",
"line1": "1234 CHICOTA AVE",
"city": "ORLANDO" }, "rentingAddresses": {
"ownsObjects": true,
"count": 0,
"arrayManager": {},
"items": [] }, "mailAddress": [
"4561 RAYCO AVE",
"",
"",
"ORLANDO",
"FL",
"32818" ] }
I'm trying to find which clients have an addrs
where the state is in "OH". My aql query is:
for client in clients.addrs
filter client.state == "OH"
return client
But I keep getting [1563] list expected
. Is there some other way to work with arrays?
you can do this:
FOR client IN clients
FILTER 'OH' IN client.addrs[*].state
RETURN client
this should return all clients which have at least one element in the "addrs" attribute with "state" == "OH"
first you have to select a doc in that collection by using filter like this:
FOR doc IN clients
FILTER doc.id == "3225C"
FOR d IN doc.addrs
FILTER d.state == "OH"
RETURN d
this will return the addrs
object in which state == "OH". if you want to get complete doc, just replace RETURN d
with RETURN doc
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With