I'm finding it hard to understand how the following code snippet (from here) works.
const { result: results } = await client.database(databaseId).container(containerId).items.query(querySpec, {enableCrossPartitionQuery:true}).toArray();
for (var queryResult of results) {
let resultString = JSON.stringify(queryResult);
console.log(`\tQuery returned ${resultString}\n`);
}
Why is the iteration done on results
rather than result
because as I understand we are creating an object with a property named result
and there is no variable elsewhere declared with the name results
?