我需要帮助,使模拟器的行为与cosmos DB一样,当使用一个自定义的分片键。当调用下面的golang mongo driver API时,仿真器期望分片键在filter参数中。否则将返回错误代码61,并提示"query in command必须针对单个分片键“
func (c *collection) replaceDocument(ctx context.Context, filter Filter, doc Document, upsert bool) (bool, error) {相同的代码在Azure cosmos DB上行为正确。下面是我使用的文档架构。我只在调用上述接口时过滤唯一的_id。
{
"_id": ==> unique non NULL key,
"shard_key": ==> non NULL string field for sharding,
other fields,
}发布于 2020-10-25 07:24:03
CosmosDB仿真器提供了在本地工作站上运行CosmosDB服务的仿真。这可能会导致仿真器行为与服务帐户行为之间的差异。更多信息可以在here上阅读。
https://stackoverflow.com/questions/64393986
复制相似问题