Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Results transformation
### Results transformation

Many times index results might be different than objects that you are interested in to work with. RavenDB supports a few mechanism of performing transformations on the query results.
To achieve it you are able to use the following methods:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#OfType (As)
##### OfType (As)

RavenDB provides a feature called [Live Projections](../static-indexes/live-projections) that offers the ability to transform results of a query on a server side.
In order to use it in the Client API you have to use `OfType<T>` (`As<T>`) extension method accessible from `Raven.Client` namespace.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##ProjectFromIndexFieldsInto (AsProjection)
#### ProjectFromIndexFieldsInto (AsProjection)

The `ProjectFromIndexFieldsInto<T>` (`AsProjection<T>`) method (extension accessible from `Raven.Client` namespace) provides the way to change the type of a query result according to *stored fields in an index*.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#TransformResults
##### TransformResults

If you want to do a client side results transformation in most cases it will be enough to you use standard Linq `Select` method.
However if your intention is to create a bit more complex projection then `TransformResults` customization method might be useful.
An advantage of this approach is that you have an access to the executed index query and the collection of all returned results.

In order to use this method you have to `Customize` your query as is in the example presented below.

##Example
###### Example

Let's assume that we have the following classes:

Expand Down
13 changes: 7 additions & 6 deletions version_2_5/docs/http-api/http-api-attachments.markdown
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#HTTP API - Attachment Operations

##HTTP API - Attachment Operations

Raven supports the concept of attachments. The attachments are binary data that are stored in the database and can be retrieved by a key.

## PUT
#### PUT

Perform a PUT request to /static/{attachment key} to create the specified attachment at the given URL:

Expand All @@ -22,7 +23,7 @@ It is important to note that a PUT in RavenDB will always create the specified a

While putting an attachment, it is possible to store metadata about it using HTTP Headers. By default a standard `Content-Type` HTTP header is always stored, however any custom header that you defined will be saved as well. When the attachment is next retrieved by GET request, its metadata are sent back to the client.

## GET
#### GET
Retrieving an attachment is done by performing an HTTP GET on the following URL:

{CODE-START:plain /}
Expand All @@ -37,7 +38,7 @@ For example, the following request:

Will retrieve an attachment whose key is "users/ayende.jpg", the response to the request is the exact byte stream that was stored in a previous [PUT](http://ravendb.net/docs/http-api/attachments/http-api-put-attachments?version=2.0) request.

## DELETE
#### DELETE

Perform a DELETE request to delete the attachment specified by the URL:

Expand All @@ -53,7 +54,7 @@ For a successful delete, RavenDB will respond with an HTTP response code 204 No

The only way a delete can fail is if [the etag doesn't match](http://ravendb.net/docs/http-api/http-api-concurrency?version=2.0), even if the attachment doesn't exist, a delete will still respond with a successful status code.

##HEAD
####HEAD

To retrieve only metadata of an attachment execute a HEAD request:

Expand All @@ -63,7 +64,7 @@ To retrieve only metadata of an attachment execute a HEAD request:

For a successful delete, RavenDB will respond with an HTTP response code 200 OK. Metadata will be contained in response headers.

##POST
####POST

Perform a POST request to update attachment metadata:

Expand Down
22 changes: 13 additions & 9 deletions version_2_5/docs/http-api/http-api-multi.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Commands on multiple documents

## GET
## Commands on multiple documents

### GET

We can address documents directly by using their key (in the following example, the key is 'users/ayende'):

Expand Down Expand Up @@ -161,7 +162,7 @@ Besides requesting by using POST to get multiple documents you can also use HTTP
> curl -X GET http://localhost:8080/queries?id=users/ayende"&"id=users/oren
{CODE-END /}

## Set based operations
### Set based operations

Typically, document databases don't support set based operations. Raven does it for deletes and updates. For inserts, you can POST to the [bulk_docs](http-api-multi#batching-requests) endpoint (this is how the Client API behaves).

Expand All @@ -174,7 +175,7 @@ Note that Raven indexes are allowed to be stale. If the index for the set based

The analogous Client API reference section you will find [here](../client-api/set-based-operations).

### Set based deletes
#### Set based deletes

For example, let us say that we wanted to delete all the inactive users, we can define an index for the user activity status:

Expand All @@ -198,7 +199,7 @@ This is the equivalent for:
WHERE IsActive = 0
{CODE-END /}

###Set based updates
####Set based updates

Set based updates work very similarly to set based deletes. They require an index to operate on an a query for this index. But they use the [PATCH format](../http-api/http-api-single#patch) as their payload. For example, if we wanted to mark all the users who haven't logged on recently as inactive, we could define the following index:

Expand All @@ -225,7 +226,8 @@ This is the equivalent for:
WHERE LastLoginDate < '2010-05-27'
{CODE-END /}

##Batching requests
###Batching requests

RavenDB supports batching multiple operations into a single request, reducing the number of remote calls and allowing several operations to share the same transactions.
Request batching in RavenDB is handled using the '/bulk_docs' endpoint, which accepts an array of operations to execute. The format for the operations is:

Expand Down Expand Up @@ -293,8 +295,10 @@ This can be executed using curl with the following syntax:
]
{CODE-END /}

###Concurrency
####Concurrency

If an etag is specified in the command, that etag is compared to the current etag on the document on the server. If the etags do no match, a 409 Conflict status code is returned. In such a case, the entire operation fails and non of the updates that were tried will succeed.

###Transactions
All the operations in the batch will succeed or fail as a transaction. Other users will not be able to see any of the changes until the entire batch completes.
####Transactions

All the operations in the batch will succeed or fail as a transaction. Other users will not be able to see any of the changes until the entire batch completes.
18 changes: 11 additions & 7 deletions version_2_5/docs/http-api/http-api-single.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#HTTP API - Single Document Operations
##HTTP API - Single Document Operations

##GET
###GET

Perform a GET request to read a JSON document from its URL:

Expand All @@ -24,7 +24,8 @@ If the URL specified does not point to a valid document, RavenDB follows HTTP co

HTTP/1.1 404 Not Found

##PUT
###PUT

Perform a PUT request to /docs/{document_id} to create the specified document with the given document id:

{CODE-START:json /}
Expand All @@ -43,7 +44,8 @@ It is important to note that a PUT in RavenDB will always create the specified d

A PUT request to /docs without specifying the document id in the URL is an invalid request and RavenDB will return a HTTP 400 Bad Request response code.

##POST
###POST

Perform a POST request to the /docs area to create the specified document and allow RavenDB to assign a unique id to it:

{CODE-START:json /}
Expand All @@ -62,7 +64,7 @@ It is important to note that a repeated POST request for the same document will

A POST to a document URL is an invalid request and RavenDB will return a HTTP 400 Bad Request response code.

##PATCH
###PATCH

Any single document within RavenDB can be updated without replacing the entire document with a PUT. You can do it either by using [Client API](../client-api/partial-document-updates) or by creating a PATCH request. The PATCH command allows Raven to implement field level concurrency.

Expand Down Expand Up @@ -91,7 +93,8 @@ For the purposes of these examples, suppose we start with this document:
comments: [ {author: 'ayende', text: 'good post'} ] }"
{CODE-END /}

###Patch Operations
####Patch Operations

Raven supports the following patch operations:

* Set - Set a property to a new value (optionally creating the property).
Expand Down Expand Up @@ -497,7 +500,8 @@ A subsequent GET of this document would show that the first operation worked, bu

Using this approach, you can make an atomic change to the a particular part of a document safely.

## DELETE
### DELETE

Perform a DELETE request to delete the JSON document specified by the URL:

{CODE-START:plain /}
Expand Down