一些背景資料
我有一個使用 sql api 的 Cosmos 資料庫。在這里,我有一個看起來像這樣的檔案:
{
"id": "123",
"city": "myCity",
"address": "myAddress"
}
id用于id,city用于partitionKey。
假設我執行 Upsert 并將下面的物件作為有效負載并將值"myCity"作為 partitionKey 傳遞,它會插入一個新檔案還是會更新已經存在的檔案?
{
"id": "123",
"city": "anotherCity",
"address": "myAddress"
}
在 .net 中,Upsert 可能看起來像這樣
await myRepository.UpsertItemAsync(myObject, "myCity");
問題
進入 CosmosDB 容器的 Upsert 是否只需要在 ID 上匹配,還是必須在 ID 和 PartitionKey 上都匹配才能執行更新?
uj5u.com熱心網友回復:
進入 CosmosDB 容器的 Upsert 是否只需要在 ID 上匹配,還是必須在 ID 和 PartitionKey 上都匹配才能執行更新?
它必須匹配 Id 和 PartitionKey 才能執行更新。Id 和 PartitionKey 的組合是 Cosmos DB 容器中檔案的唯一識別符號。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/527375.html
標籤:。网天蓝色宇宙数据库
上一篇:如何檢查泛型型別是否實作了介面
