We will add the Language
property to a Country
document. This property will be set to EN
(English) if the country's ContinentCode
is NA
and ES
(Espagnol) if ContinentCode
is SA
. We want to apply this on all documents in the Countries
collection.
Start Visual Studio and open the
RavenDB_Ch06
project.Add the following code snippet to the
Main()
method:Save all the files, build and run the solution.
You just updated the Countries
collection using a ScriptedPatchRequest
written in JavaScript. During this update operation, you added a new property named language and populated it with values: EN
or ES
based on the country's ContinentCode
.
To apply the update on Countries
collection, you call the UpdateByIndex()
method on the DatabaseCommands
object (lines 129 to 142). This method performs a set-based update using the specified index and will not allow the update operation on a stale index.
This method requires the following three...