Quantcast
Channel: Mobile - Couchbase Forums
Viewing all articles
Browse latest Browse all 1117

Update array field of a document

$
0
0

I am getting the document to be updated like this. Idea is to add one more dictionary/map element to the array. The document looks like this:

{id:'id', cycles: [{"id":1, "name":"cycle 1"}] }

now i want to add cycle 2 to the cycles array but got stuck here:

Document doc = database.getDocument(docId);

// get the field to be updated, which is an array.
Array ar = doc.getArray(“cycles”); // getting the data here well.
MutableDocument mutableDocument = document.toMutable();
//what comes here please?
database.save(mutableDocument);

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1117

Trending Articles