I have a database with documents and I would like to retrieve some data from it providing an array of keys to a Foxx service. It works using a single string but I'm missing something about implementing arrays.
UPDATED
router.get('/keys', function (req, res) {
const keys = db._query(aql`
FOR huis IN test
FILTER huis._key in ${req.queryParams.keys}
RETURN {
'adres': huis.adres,
'postcode': huis.postcode,
'plaats': huis.plaats
}
`);
res.send(keys);
})
.queryParam('keys', joi.array().required(), 'query to search for')
.response(joi.array()
.items(
joi.string().required()
)
.required(), 'List of house keys.')
.summary('List house keys')
.description('Makes LAT LNG from house keys.');
The joi.array() results in a nice interpretation by Arango on the Services overview page as shown below. But I handle it wrong because it returns a 404.
If you're passing an array, you will need to use a queryParam or bodyParam and not a pathParam.
I'd recommend change your router path to router.get('/keys', function (req, res) {
and then access the value as req.queryParams.keys
.
When you send the array via a queryParam you have a few options, either as /keys?keys=1234,5678
or as /keys?keys=1234&keys=5678
.