【发布时间】:2020-10-16 17:44:10
【问题描述】:
在使用自定义分片键时,我需要帮助以使模拟器的行为与 cosmos DB 相同。在调用以下 golang mongo 驱动程序 API 时,模拟器期望分片键位于 filter 参数中。否则,它将返回错误代码 61,并显示消息“命令中的查询必须针对单个分片键”
func (c *collection) replaceDocument(ctx context.Context, filter Filter, doc Document, upsert bool) (bool, error) {
相同的代码在 Azure cosmos DB 上运行正常。下面是我使用的文档架构。我仅在调用上述 API 时过滤唯一的_id。
{
"_id": ==> unique non NULL key,
"shard_key": ==> non NULL string field for sharding,
other fields,
}
【问题讨论】:
标签: azure-cosmosdb-mongoapi azure-cosmosdb-emulator