可以 运行 存储过程使用 documentDB SDK Python?

Possible to run Stored Procedure using documentDB SDK for Python?

我正在使用 Tornado 和 pydocumentDB 运行 Azure 上的存储应用程序。我还有一个存储过程:

function userIDSproc() {
    var collection = getContext().getCollection();

    // Query documents and take 1st item.
    var isAccepted = collection.queryDocuments(
        collection.getSelfLink(),
        "SELECT * FROM root r WHERE r.id='user_ids_counter'",
        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) getContext().getResponse().setBody('no docs found');
            else tryUpdate(feed[0])
        });

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

    function tryUpdate(document){
        document.counter += 1;
        getContext().getResponse().setBody(document['counter']);
        var isAccepted = collection.replaceDocument(document._self, document, function (err, document, options) {
            if (err) throw err;
            // If we have successfully updated the document - return it in the response body.
            getContext().getResponse().setBody(document);            
        });
    }

我想做的是在每次生成新用户并将他们的文档添加到集合中时增加我的 user_ids 文档的 counter 属性。是否可以调用该 Sproc,更新计数器,然后查询新计数器的文档,然后使用该新计数器作为新用户的 ID? GitHub 上的 documentDB SDK 显示了一些方法,例如 QueryStoredProcedures(self, collection_link, query, options=None): ReadStoredProcedures(self, collection_link, options=None):,但没有实际执行的方法。

对于DocumentDB Python SDK,您可以调用ExecuteStoredProcedure(self, sproc_link, params, options=None)

您可以在此处找到 SDK 单元测试中的简短示例:

https://github.com/Azure/azure-documentdb-python/blob/e605e7ca7b1ddd2454f1014f536a0fded9e6f234/test/crud_tests.py#L3408-L3409