Hi CB Team,
Currently i am observing that when we perform collection.upsert operation and if document does not exist CB throw Document Not Found exception, basically it’s should create on if key is not found. Can someone help me to understand ? beside that where i find can full document of upsert/insert/replace …?
MutationResultupsert(String id, Object content) Upserts a full document which might or might not exist yet.
Based on SDK document when use collection.upsert it’s should create document if document does not exist but currently it’s throwing document not found exception. I have shared the link in my previous note.
if you have any other link for that SDK document you can share …
@mehul I’m pretty sure that’s not the case. Upsert will insert if it doesn’t exist and replace it if it does. Do you have a piece of sample code you can share that demonstrates your issue?
Here is the code snippet @Override
public MutationResult upsertDocument(String key, JsonObject doc) {
return collection.upsert(key, doc,UpsertOptions.upsertOptions().expiry(getInstant(doc)));
}
public Instant getInstant (JsonObject doc){
return Instant.ofEpochSecond(Integer.parseInt(String.valueOf(doc.get(“expiryTime”))));
}