-1

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);
  }
};

1 Answer 1

1

Well, I found a way to accomplish what I want. It may not be the only way.

SELECT * FROM r WHERE r.city = {city} AND r.district = {district} AND ToString(r.max_number_of_people) = {people}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.