I am trying to run the following query against my cosmos db using Node.js.
const querySpec = {
query: "SELECT * FROM Users u WHERE u.id = @email",
parameters: [
{
name: "@email",
value: "[email protected]"
}
]
};
const { result: results } = client.database(databaseId).container(containerId).items.query(querySpec).toArray();
if (results.length == 0) {
throw "No matching user";
} else if (results.length > 1) {
throw "Account found";
}
const user = results[0];
console.log(user);
however I keep getting the error TypeError: results is undefined. The query works just fine in the data explorer. databaseId and containerId print the values I need them to if I use console.log.
Why might i be getting this error?