See http://docs.appcelerator.com/arrowdb/latest/#!/guide/search_query and note the $all and $elemMatch operators
For this data set:
{
"success": true,
"request-id": "28551a17-8977-452a-9e34-2778d44e8b0a",
"key": "myaccounts",
"myaccounts": [
{
"id": "55e717634d27fa0bd89f1728",
"name": "Account4",
"type": "Prospect",
"opportunities": [
20
]
},
{
"id": "55e717084d27fa0bd89f15b9",
"name": "Account3",
"type": "Client",
"opportunities": [
1,
3,
9
]
},
{
"id": "55e71143d12d0b0beb9d8329",
"name": "Account2",
"type": "Client",
"opportunities": [
1,
4,
8
]
},
{
"id": "55e7112d4d27fa0bd89ee72e",
"name": "Account1",
"type": "Prospect",
"opportunities": [
1,
3,
7
]
}
]
}
The query where={"opportunities":{"$all":[ 3 ]}} returns the following:
{
"success": true,
"request-id": "e18e5ee1-8c5f-4705-9b46-4c88eb6aaf91",
"key": "myaccounts",
"myaccounts": [
{
"id": "55e717084d27fa0bd89f15b9",
"name": "Account3",
"type": "Client",
"opportunities": [
1,
3,
9
]
},
{
"id": "55e7112d4d27fa0bd89ee72e",
"name": "Account1",
"type": "Prospect",
"opportunities": [
1,
3,
7
]
}
]
}
The query where={"opportunities":{"$all":[ 1 ]}} returns the following:
{
"success": true,
"request-id": "05e420b4-eb42-4abc-a910-a928ab910d65",
"key": "myaccounts",
"myaccounts": [
{
"id": "55e717084d27fa0bd89f15b9",
"name": "Account3",
"type": "Client",
"opportunities": [
1,
3,
9
]
},
{
"id": "55e71143d12d0b0beb9d8329",
"name": "Account2",
"type": "Client",
"opportunities": [
1,
4,
8
]
},
{
"id": "55e7112d4d27fa0bd89ee72e",
"name": "Account1",
"type": "Prospect",
"opportunities": [
1,
3,
7
]
}
]
}
The query where={"opportunities":{"$all":[ 1,3,9 ]}} returns the following:
{
"success": true,
"request-id": "d354553b-02c5-4d80-a443-956a2e940a25",
"key": "myaccounts",
"myaccounts": [
{
"id": "55e717084d27fa0bd89f15b9",
"name": "Account3",
"type": "Client",
"opportunities": [
1,
3,
9
]
}
]
}
The query where={"opportunities":{ "$elemMatch": {"$gte": 15}}} returns the following:
{
"success": true,
"request-id": "dce7b2a0-fc9c-4879-b21b-5b582e461c3d",
"key": "myaccounts",
"myaccounts": [
{
"id": "55e717634d27fa0bd89f1728",
"name": "Account4",
"type": "Prospect",
"opportunities": [
20
]
}
]
}