1

I am given the following JSON structure:

{
    "document": {
        "sections": {
            "x": {
                "title": "foo"
            },
            "y": {
                "title": "bar"
            }
        }
    }
}

How do I update value of the title property for a given section using the HTTP API?

I would like to provide a path (string) to get to the property.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
Raj
  • 13
  • 2
  • 1
    You should be able to use a scripted patch command, but I ran into a bug while producing an example for you. It works with the bulk_docs interface, but not for a single doc. See my comments [in the bug report](http://issues.hibernatingrhinos.com/issue/RavenDB-810) – Matt Johnson-Pint Jan 09 '13 at 00:09
  • Thanks @MattJohnson for logging the bug. ScriptedPatchRequest -- This is an ultimate feature in Raven DB that I missed out completely (probably due to the faint documentation out there and the name). Having IronJS support is AWESOME! It definitely deserves more attention and a cleaner impl as Matt pointed out. Ayende’s blog post on this topic is helpful - http://ayende.com/blog/157185/awesome-ravendb-feature-of-the-day-evil-patching – Raj Jan 09 '13 at 17:15

1 Answers1

0

This was fixed in build 2254. You should now be able to issue a single scripted patch like this:

EVAL http://localhost:8080/docs/foos/1

{Script:"this.document.sections.x.title = newTitle;",Values:{"newTitle":"Whatever"}}
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575