Hi Duy,
Your code is looks fine. Are you using CBL Andriod v1.1.0? We will try to
reproduce the problem internally at couchbase.
> the results of response documents are not order like list. Thanks so much
everyone!
Query result is ordered by key.
Thanks
Hideki
On Thursday, January 21, 2016 at 8:59:27 AM UTC-8, Duy Bui wrote:
>
> 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/a7421bae-aef2-4efc-ab07-f8e647f65e45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.