我写了一个简单的波斯菊存储过程
function a()
{
var context = getContext();
var response = context.getResponse();
var collection = context.getCollection();
var collectionLink = collection.getSelfLink();
var filterQuery = 'SELECT * FROM c';
collection.queryDocuments(collectionLink, filterQuery, { pageSize: -1 },
function (err, documents) {
if (err) throw err;
if (!documents || !documents.length) {
var response = getContext().getResponse();
response.setBody('No Records found');
}
else {
response.setBody(response.getBody());
}
});
}
但是,在执行时,我总是会得到“找不到记录”,尽管在单独运行查询时,我也会得到记录。我也给分区键值。
答案 0 :(得分:0)
假设您提供了不正确的分区键,以便找不到数据。
SP代码:
function a()
{
var context = getContext();
var collection = context.getCollection();
var collectionLink = collection.getSelfLink();
var filterQuery = 'SELECT * FROM c';
collection.queryDocuments(collectionLink, filterQuery, { pageSize: -1 },
function (err, documents) {
if (err) throw err;
if (!documents || !documents.length) {
var response = getContext().getResponse();
response.setBody('No Records found');
}else {
var response = getContext().getResponse();
response.setBody(documents);
}
});
}
样本数据:
提供分区键并执行: