LoginSignup
0
0

More than 3 years have passed since last update.

Azure CosmosDB でPKが設定されていないドキュメントを削除する (Java SDK)

Posted at

PK が値として設定されているドキュメントを削除するには

options.setPartitionKey(new PartitionKey(pkValue));
client.deleteDocument(doc.getSelfLink(), options);

とすればよいのですが、PKが設定されていない文書を

options.setPartitionKey(null);
client.deleteDocument(doc.getSelfLink(), options);

client.deleteDocument(doc.getSelfLink(), null);

のように削除しようとするとなぜか

PartitionKey value must be supplied for this operation.

のエラーが返されます。

これを回避するためには

// com.microsoft.azure.documentdb.Undefined
options.setPartitionKey(new PartitionKey(Undefined.Value()));

としないといけない仕様となっているようです。
Javaのみならず、他の言語でも同様のようです。

(そもそも値が存在しないのだから null で通すようにしてくれたらいいのに、と思うのですが)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0