且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Cosmos db readDocument API在存储过程中不起作用

更新时间:2023-02-14 12:33:59

根据迈克尔的建议,我的示例现在可以工作了,下面是代码

According to Michael's suggestion, my sample works now, here is the code

function testRead() {
    var collection = getContext().getCollection();
    var response = getContext().getResponse();

    var docId =  collection.getAltLink() + '/docs/myDocId';

    // Query documents and take 1st item.
    var isAccepted = collection.readDocument(docId, {}, function (err, doc, options) {
        if (err) throw err;

        response.setBody(JSON.stringify(doc));
    });

    if (!isAccepted) throw new Error('The query was not accepted by the server.');
}