Pergunta

I'd like to write my own simple desktop based RavenDB explorer, similar to the Web UI. This is for learning Raven, mostly.

So my first task is to read all documents from the db, doesn't matter what app they belong to. I'd like to achieve this using the client API, but it seems like both session.Query and session.LuceneQuery require class specifier.

What API should I use for this task?

Foi útil?

Solução

The Client API requires a type because it's designed to work with CLR POCO and so handles the conversion (from Json) for you.

You will need to work directly with the Json in your case as you don't know the type. This is what the Web UI does. I'd recommend looking through the Java-Script code to see how it's done.

Also there is always a default index called "Raven/DocumentsByEntityName" that you can query. This indexes the "Raven-Entity-Name" (corresponding to the CLR type), that is stored in a documents metadata. This is what Raven uses to allow it to convert the Json to a CLR type. See the docs for more info

Outras dicas

The below will extract all RavenDB documents in Json:

var docStore = new DocumentStore { Url = "http://localhost:8080" };
using (docStore.Initialize())
{
    var docs = docStore
        .DatabaseCommands
        .Query("Raven/DocumentsByEntityName", new IndexQuery());
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top