Hi everyone,
I'm new in Couchbase in Android. I faced a problem with *document-id* when
save and get a list of document in database. I saved data into document
with my id, here is my code to do that:
Document document=cbDatabase.getDocument("my_id");
Map<String,Object> docContent= new HashMap<String, Object>();
docContent.put("title", node.getTitle());
docContent.put("firstname", node.getFirstName());
docContent.put("lastname", node.getLastName());
try{
document.putProperties(docContent);
} catch (CouchbaseLiteException e){
Log.e(TAG, "Cannot write document to database", e);
}
But when I get that document, the return of id is not my custom ID, it's a
default id (created by UUID). Here is the code to get id:
Query allDocumentsQuery= cbDatabase.createAllDocumentsQuery();
QueryEnumerator queryResult=allDocumentsQuery.run();
for (Iterator<QueryRow> it=queryResult;it.hasNext();){
QueryRow row=it.next();
String id=row.getDocumentId(); // I get id here and the result is an UUID
(the default id)
}
Please give some advise and answer.
And I have another question too. I have a list of POJO object and I want to
insert each of object to document with custom ID is index of that list. And
here is my question: Why when I query this database, the results of
response documents are not order like list. Thanks so much everyone!
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/997137e4-2760-47c3-bffa-92100c8ccf8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.