Re: [RavenDB] trying to get a single document with raven commandBase

21 views
Skip to first unread message

Grisha Kotler

unread,
May 26, 2016, 8:00:36 AM5/26/16
to rav...@googlegroups.com

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Grisha Kotler l RavenDB Core Team Developer Mobile: +972-54-586-8647

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/


On 26 May 2016 at 14:13, Stacey <stacey.ci...@gmail.com> wrote:
I'm trying to write some code for a pull request, and it requires that I get a single document using the HTTP commands and the `commandBase` layout. I've never used Raven with the HTTP commands, so I'm having some trouble with this. I've gotten it to work using the already existing multi_get from getCollectionCountCommand, but I feel it's better to get a single document. This is what I have so far...

        var requests = this.collections.map(collection => {
            return {
                Url: "/queries/",
                Headers: {},
                Query: "?id=" + queryUtil.escapeTerm("document id goes here")
            }
        });
        this.post("/multi_get?parallel=yes", JSON.stringify(requests), this.ownerDb, null, 0)
            .done((result) => {
                task.resolve(this.collections);
            })
            .fail((response: JQueryXHR) => {
                this.reportError("Failed to fetch collections count", response.responseText, response.statusText);
                task.reject(response);
            });

My problem is that I'm a little confused about how the post function works here, and what it's expecting to do a `GET`. As I understand it from http://ravendb.net/docs/article-page/3.0/http/client-api/commands/documents/get#get, the URL I'm inevitably wanting to send would look like..

http://{server}/databases/{database}/queries/id={document id}

I tried removing the multi_get?parallel=yes and the url came out without any of the parameters. Is there an example of using this code for a single document request?

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages