Eric Johnson
Eric Johnson

Reputation: 59

How can RavenDB patch JSON objects?

Using Raven Studio's patch interface, I have the following patch script: this.Market = this.Market.replace(" Los Angeles","Los Angeles") to remove a prepended space.

Which would be fine for a field with single-value strings, but my data is structured as a JSON object: "Market": [ " Los Angeles", "Chicago", " New York City"],

And running the patch throws the error, "TypeError: Object has no method 'delete'." How can I work around this?

Upvotes: 1

Views: 127

Answers (1)

Akbar Taghipour
Akbar Taghipour

Reputation: 334

var m= this.Market;
for(var i=0; i < m.length; i++) {
this.Market[i] =  m[i].replace("Los Angeles","Los Angeles");
}

Upvotes: 1

Related Questions