I'm using Azure Functions to retrieve data from a Cosmos DB. No I have the following SQL query:
SELECT * FROM r WHERE r.city = {city} AND r.district = {district} AND r.max_number_of_people = {people}
When I make a request using these as the query params: "?city=Amsterdam&district=West&people=2" I'm not getting anything back. I tried it without the people param, and then it works.
I think it has something to do with the max_number_of_people being saved as a number in my container, but I'm not sure.
What could be the issue here?
// function.json
{
"bindings": [
{
"name": "req",
"route": "restaurants/available",
"authLevel": "function",
"methods": ["get"],
"direction": "in",
"type": "httpTrigger"
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name": "restaurants",
"databaseName": "find-your-spot",
"collectionName": "restaurants",
"connectionStringSetting": "fys-d-cdb_DOCUMENTDB",
"sqlQuery": "SELECT * FROM r WHERE r.city = {city} AND r.district = {district} AND r.max_number_of_people = {people}",
"direction": "in",
"type": "cosmosDB"
}
]
}
// index.js
module.exports = async function (context, req, restaurants) {
try {
context.res.status(200).json(restaurants);
} catch (error) {
context.res.status(500).json(error);
}
};