Search code examples
androidcouchbase-lite

Couchbase Mobile 2.0 set Array in MutableDocument


I have an object with an element which is a list and the MutableDocument has a .setArray method but this is expecting an instance of com.couchbase.lite.Array. How do I go about this to set my list and save the document.

This is how my model looks like

private String signature;
private String comments;
private boolean isDraft;
public List ids;
public List fingers;


Solution

  • If you have a list of complex types you will have to handle serializing them down into their primitives and creating an array that way. So in the end you would have a mutable array object first and then add in dictionaries containing values that represent your objects (I don't know what 'Customer' and 'Bio' look like so I can't comment further). It would probably be easier to create a method that will do that for you on each class that you want to serialize. That way you can quickly and recursively create the objects for use in the database.