I am trying to write a simple stored procedure which runs a SQL query and I want to restrict the results by using MaxItemCount property. Query produces 3 documents but I want to return only 1 document. I am forcing this restriction using MaxItemCount property but that doesn't seem to be working.
function uspGetDetailsByEmailId(EmailId) {
var collection = getContext().getCollection();
var collectionLink = collection.getSelfLink();
var response = getContext().getResponse();
var recordcount = 0;
if (!EmailId) throw new Error("Please provide the EmailId for which Details need to be retrieved");
retrieveDetails();
function retrieveDetails() {
var requestOptions = {MaxItemCount: "1"};
var dbquery = {query: "SELECT * FROM c"};
var isAccepted = collection.queryDocuments(collectionLink, dbquery, requestOptions,function (err, results) {
console.log(results.length)
response.setBody(results)
if (err) throw err;
});
if (!isAccepted) {
response.setBody(null);
}
}
}