I've been reading the limited documentation and from what I've seen, this query should work.
// SAMPLE STORED PROCEDURE
function sample() {
var prefix = "";
var collection = getContext().getCollection();
var data = collection.readDocuments(collection.getSelfLink());
console.log(data);
console.log(JSON.stringify(data));
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT * FROM root r',
function (err, feed, options) {
if (err) throw err;
// Check the feed and if empty, set the body to 'no docs found',
// else take 1st element from feed
if (!feed || !feed.length) {
var response = getContext().getResponse();
response.setBody('no docs found');
}
else {
var response = getContext().getResponse();
var body = { prefix: prefix, feed: feed[0] };
response.setBody(JSON.stringify(body));
}
});
if (!isAccepted) throw new Error('The query was not accepted by the server.');
}
After all, this is just the sample query that the portal generates. The only issue is that it does not return any results.
- The collection has 7000 documents
- It is partitioned by a prop type
/EmailTypeId
- When I execute the query I am submitting partition value of
5
(which is the partition value for all current records) - I'm console.logging a call to
collection.readDocuments
which should return all docs but it just returns the valuetrue
I'm trying to return all records so I can aggregate by id and count. How can I get this query to actually return data?
Here is a sample screen shot of one of the doc schemas in the collection
Here is the input form for supplying the partition value
Update
I created a new collection as a control. This collection has no partition key and it seems the same query returns results in that collection. Therefor the issue has to be in the 2nd screen shot I provided. Perhaps I am providing the partition key incorrectly.