CreateAllDocumentsQuery ()

41 views
Skip to first unread message

Julio Albuquerque

unread,
Feb 18, 2015, 2:01:22 PM2/18/15
to mobile-c...@googlegroups.com
Hello!
I'm using CreateAllDocumentsQuery () to return all documents.
For this type of query is there any way to return the values as if it were created setMap function? (QueryEnumerator.GetRow (i) .Value)
Only through views that can emit values?

If I use linesGeral.GetRow (i) .Document.GetProperty ("name"). ToString () is too slow!
Can anyone help?
Xamarin use Android with Couchbase Lite .Net.

Julio.

Jens Alfke

unread,
Feb 18, 2015, 9:06:06 PM2/18/15
to mobile-c...@googlegroups.com
On Feb 18, 2015, at 11:01 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

For this type of query is there any way to return the values as if it were created setMap function? (QueryEnumerator.GetRow (i) .Value)
Only through views that can emit values?

I’m not quite sure what you’re asking, but the rows of an all-docs query don’t have values. (What would go in them?)

If I use linesGeral.GetRow (i) .Document.GetProperty ("name"). ToString () is too slow!
Can anyone help?

If you want to iterate over the “name” property of every document in the database, then create a view that emits that as the value for every document.

—Jens

Julio Albuquerque

unread,
Feb 19, 2015, 5:04:38 AM2/19/15
to mobile-c...@googlegroups.com
Just what NOT want to do.
Its recover as JSON or something?

Julio.

Jens Alfke

unread,
Feb 19, 2015, 11:29:53 AM2/19/15
to mobile-c...@googlegroups.com

> On Feb 19, 2015, at 2:04 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:
>
> Just what NOT want to do.
> Its recover as JSON or something?

What? I’m sorry, I don’t understand what you’re asking.

—Jens

Julio Albuquerque

unread,
Feb 19, 2015, 11:42:51 AM2/19/15
to mobile-c...@googlegroups.com

I wonder if you can recover the entire document without having created a view, and without accessing the properties one by one.

What I need is to recover the database documents through CreateAllDocumentsQuery (), but how to retrieve the full document without having to access each property?
Below is an example of the document:
{
 
"id": "E8690",
 
"nome": "+d casa interiores",
 
"fone": [
   
{
     
"numero": "34220881"
   
}
 
],
 
"razao": "caroline freitas figueredo",
 
"email": "maisdcasa...@hotmail.com",
 
"homepage": "www.alegrete.com.br/maisdecasa",
 
"complemento": "",
 
"nr": "689",
 
"cep": "97542620",
 
"cidade": "alegrete",
 
"bairro": "centro",
 
"logradouro": "20 de setembro",
 
"produto": "",
 
"latitude": "-29,7864856719971",
 
"longitude": "-55,7959747314453",
 
"facebook": "",
 
"titulos": [
   
{
     
"descricao": "bazares e presentes",
     
"peso": 7
   
}
 
],
 
"titular": [
   
{
     
"descricao": "jandira pereira freitas"
   
}
 
],
 
"type": "E",
 
"blativo": "1",
 
"venda": null,
 
"vencimento": null
}


Jens Alfke

unread,
Feb 19, 2015, 11:55:30 AM2/19/15
to mobile-c...@googlegroups.com
On Feb 19, 2015, at 8:42 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

I wonder if you can recover the entire document without having created a view,

We have API documentation that can answer these sorts of questions.

and without accessing the properties one by one.

I’m not sure what you mean by “one by one”. When you get a document, the entire doc is loaded into memory (from JSON stored in the database), and property access is random-access after that.

If you’re finding that this is too slow, it’s because by accessing the .document property of the query row you’re issuing a database fetch for every document you look at. This is exactly the kind of performance issue that views help with — the value of an emitted row is stored directly in the index, so it takes no extra fetches to read it.

I don’t understand why you’re so reluctant to create a view.

—Jens

Zack Gramana

unread,
Feb 19, 2015, 12:19:03 PM2/19/15
to <mobile-couchbase@googlegroups.com>
The QueryEnumerator gives your access to the emitted .Key and .Value, as well as the full .Document. Accessing the first two is very fast. Accessing the latter is slower.

The idea behind Views, and indexes in general, is to provide a subset of the database's dataset that is optimized for finding certain records. This is why Jens keeps suggesting using a View.

Now that you have provided us with a sample document, why don't you tell us what goal you're trying to achieve and we can try to give you more specific guidance.

On Feb 19, 2015, at 8:42 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

--
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 mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/8c4688db-4f2d-49e8-81ce-6a84d4f53849%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages