从Azure文档对象检索ObjectId

时间:2020-06-17 11:57:55

标签: python azure azure-functions azure-cosmosdb-mongoapi

我正在使用python中的azure cosmosdb实现变更供稿。 python azure函数被触发,我得到了已编辑文档的Azure文档对象。唯一的问题是mongodb对象的objectId以加密格式出现,我无法检索到。有没有一种方法可以解密对象ID。所有其他元素都很好。

Azure Document Object documentation

我在azure函数中的python代码如下。

import logging
import azure.functions as func

def main(documents: func.DocumentList) -> str:

    if documents:
        logging.info('Document id: %s', documents[0]['id'])
        logging.info('%s',documents[0])
        logging.info("----------")
        logging.info('%s',type(documents))
        s=documents[0].to_json()
        logging.info('%s',s)

我的输出看起来像这样。

2020-06-17T11:14:37Z   [Information]   Document id: NWRmODhlMWNkNTg4ZjAwYzMyYTNjOWNk
2020-06-17T11:14:37Z   [Information]   <azure.Document at 0x7f19ae54e710>
2020-06-17T11:14:37Z   [Information]   ----------
2020-06-17T11:14:37Z   [Information]   <class 'azure.functions._cosmosdb.DocumentList'>
2020-06-17T11:14:37Z   [Information]   {"id": "NWRmODhlMWNkNTg4ZjAwYzMyYTNjOWNk", "$t": 3, "$v": {"_id": {"$t": 7, "$v": "]\u00f8\u008e\u001c\u00d5\u0088\u00f0\f2\u00a3\u00c9\u00cd"}, "name": {"$t": 2, "$v": "abcde"}, "title": {"$t": 2, "$v": "title"}}}

这里的$ t和$ v是什么。同样,我的_id属性的格式为ObjectId(“ 5df88cfad588f00c32a3c9ca”)以加密格式出现。有没有办法检索objectId。

发现了类似的问题here ..

0 个答案:

没有答案