CreateAllDocumentsQuery

54 views
Skip to first unread message

Julio Albuquerque

unread,
Jul 21, 2015, 6:40:14 PM7/21/15
to Couchbase Mobile
Hi,
You can issue values without using Views? Only using db.CreateAllDocumentsQuery ()?

Julio.

Jens Alfke

unread,
Jul 21, 2015, 6:43:40 PM7/21/15
to mobile-c...@googlegroups.com

On Jul 21, 2015, at 3:40 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

You can issue values without using Views? Only using db.CreateAllDocumentsQuery ()?

Yes. An all-documents query is basically like a view query whose map function calls emit(doc._id, nil). That is, the keys are the document IDs.

—Jens

Julio Albuquerque

unread,
Jul 21, 2015, 6:58:14 PM7/21/15
to Couchbase Mobile
Okay, but what about values? That is, as I recover all the complete document?
I have to use database.GetDocument ("key")?

Julio

Jens Alfke

unread,
Jul 21, 2015, 8:24:36 PM7/21/15
to mobile-c...@googlegroups.com

On Jul 21, 2015, at 3:58 PM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

Okay, but what about values? That is, as I recover all the complete document?
I have to use database.GetDocument ("key")?

You can use queryRow.GetDocument().
We have documentation of all-document queries.

—Jens

Julio Albuquerque

unread,
Jul 22, 2015, 10:05:43 AM7/22/15
to Couchbase Mobile

Jens,
But the values have to read the properties one by one?
It does not have a way to return the entire document as a JSON?




            var query = db.CreateAllDocumentsQuery ();
             query
.AllDocsMode = AllDocsMode.AllDocs;
             
var rows = query.Run ();
             
List<Cadastro> Geral = new List<Cadastro> (rows.Count);
             
foreach (var row in rows) {
                 
var doc = row.Document;
                 
Geral.Add( new Cadastro() {
                     
Nome = doc.GetProperty<string> ("nome"),
                     
Razao = doc.GetProperty<string> ("razao"),
                     
Cidade = doc.GetProperty<string> ("cidade"),
                     
Bairro = doc.GetProperty<string> ("bairro"),
                     
Logradouro = doc.GetProperty<string> ("logradouro")
                 
});
             
}

Jens Alfke

unread,
Jul 22, 2015, 12:53:57 PM7/22/15
to mobile-c...@googlegroups.com

On Jul 22, 2015, at 7:05 AM, Julio Albuquerque <jcezar.al...@gmail.com> wrote:

But the values have to read the properties one by one?
It does not have a way to return the entire document as a JSON?


Document.GetProperties()

I think it’ll probably be quicker for you to read the API documentation than to ask questions here one at a time.

—Jens

Julio Albuquerque

unread,
Jul 22, 2015, 1:08:29 PM7/22/15
to Couchbase Mobile

Jens,
in fact I have read and already developed.
Just I wanted to know if there are other ways, because I think too slow.

Only use Couchbase Lite to handle the synchronization.
View think too slow.
I'm using Linq Lucene.Net in this way was very fast.
Only is impacting to retrieve all documents (12,000) of Couchbase Lite, even without Views, it is slow.

Thank you anyway.
Julio
Reply all
Reply to author
Forward
0 new messages