Retrieve the data from couchbase lite


i’m struck on following issue

my doc structure is

“expId” : “”,
“title” : “expenses”,
“bizId” : {“type” : “string”},
“brcId” : {“type” : “string”},
“lnId” : {“type” : “string”},
“Expenses” : [{}]

here the Expenses was an array field and my problem while adding expenses on future

case #1 first time insert was successful

case #2 i’m going to add a new expense then need to update on same doc under Expenses field here i can’t pass exist doc id because it may be exist or not

refer case #1 there is no doc id it’s just a insertion but in case #2 there is a doc may exist and i can’t pass doc id while insert second data under Expenses.

please help me to fix this because there is no query execution in mobile

It sounds like your code will just need to behave differently if the doc exists already or not.

doc = getDoc(docId)
if doc {
// insert new doc
} else {
// update the fields and save it

Can you post a code sample and mention which platform and version you are using?