使用Node.js将嵌套文档插入到DocumentDB文档中

将嵌套文档插入到下面的最佳方法是什么?

{ "id": "3af62b94-2031-4b85-9fd3-e13e7217d382", "Email": "test@ingeniuus.com", "Name": "test", "OrgRoles": null, "UpdatedDate": "2017-11-10T10:49:11.1962998Z", "CreatedDate": "2017-11-10T10:49:05.6247018Z", "IsDeleted": true, "_rid": "KFokAOUDHwEtAAAAAAAAAA==", "_self": "dbs/KFokAA==/colls/KFokAOUDHwE=/docs/KFokAOUDHwEtAAAAAAAAAA==/", "_etag": "\"00001e00-0000-0000-0000-5a0584270000\"", "_attachments": "attachments/", "_ts": 1510310951 } 

理想情况下,我想追加OrgRoles,以便文档看起来像:

 { "id": "3af62b94-2031-4b85-9fd3-e13e7217d382", "Email": "test@ingeniuus.com", "Name": "test", "OrgRoles": null, "Devices": [ "ID": "765476547", "name": "myDevice" ], "UpdatedDate": "2017-11-10T10:49:11.1962998Z", "CreatedDate": "2017-11-10T10:49:05.6247018Z", "IsDeleted": true, "_rid": "KFokAOUDHwEtAAAAAAAAAA==", "_self": "dbs/KFokAA==/colls/KFokAOUDHwE=/docs/KFokAOUDHwEtAAAAAAAAAA==/", "_etag": "\"00001e00-0000-0000-0000-5a0584270000\"", "_attachments": "attachments/", "_ts": 1510310951 } 

我目前正在使用Node.js DocumentDB客户端来做我的search,所以想继续使用这个,但似乎无法看到一个推或更新或同等的方法在那里

你必须调用readDocument ,在本地进行更新,然后使用replaceDocument进行更新。