且构网

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

没有PartitionKey,Cosmos DB存储过程无法执行

更新时间:2023-01-14 14:17:23

如果集合所存储的过程被注册为一个 单分区集合,则事务范围为所有 馆藏内的文件.如果集合已分区, 然后在一个存储区的事务范围内执行存储过程 单分区键.然后必须执行每个存储过程 包括与范围相对应的分区键值 交易必须在此之下进行.

If the collection the stored procedure is registered against is a single-partition collection, then the transaction is scoped to all the documents within the collection. If the collection is partitioned, then stored procedures are executed in the transaction scope of a single partition key. Each stored procedure execution must then include a partition key value corresponding to the scope the transaction must run under.

您可以参考上面提到的

You could refer to the description above which mentioned here.

通过将分区键设置为Undefined.Value来逃避上述规则是不可能的.在分区集合中执行存储过程时,必须提供分区键.

It's impossible to escape the above rule by setting the partition-key to Undefined.Value. You must provide the partition key when you execute stored procedure in partitioned collection.

仍然存在,以便我可以获取文档而无需通过 分区键?

is there anyway so that I can fetch the documents without passing the PartitionKey?

执行查询sql时,可以在FeedOptions参数中将EnableCrossPartitionQuery设置为true.(存在性能瓶颈).

You could set EnableCrossPartitionQuery to true in FeedOptions parameter when executing query sql.(has performance bottleneck).

希望它对您有帮助.