Read document from DocumentDB by ID using Node.js fails

后端 未结 1 498
被撕碎了的回忆
被撕碎了的回忆 2021-01-24 05:20

I\'m trying to read a single document from DocumentDB by using the document ID. The collection has four fields, author being the partition key.

{
           


        
相关标签:
1条回答
  • 2021-01-24 05:59

    It's an oversight in the documentation for the node.js client, but you have to add an options.partitionKey property to the optional second parameter in your readDocument(link, options, callback) call.

    It's also an oversight in the docs but I think partitionKey needs to be an array with a single element (e.g. {options: {partitionKey: ["myKey"]}} [UPDATE: I'm told that it will now work with a single partition key value but I haven't confirmed it myself.]

    Alternatively, you can set options.enableCrossPartitionQuery property to true but that is less efficient.

    0 讨论(0)
提交回复
热议问题