Patch Collection - Conditional Updates

65 views
Skip to first unread message

mcpdeve...@gmail.com

unread,
Mar 27, 2015, 12:45:34 PM3/27/15
to rav...@googlegroups.com

Hi ,

I have tons of thousands in collection. I would like to replace a word with another word for all tons of document collection.

Is possible to update those with patch collection ? If yes , how to do it ?

Tal Weiss

unread,
Mar 27, 2015, 1:16:39 PM3/27/15
to rav...@googlegroups.com

The best way is through the studio since it has tools to test your script. Notice that the documents button is actually a combo box click the down arrow choose patch then choose collection insert your script lets say you have a field name title than you write this.title = title.replace("foo", "bar")
(

--
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.

mcpdeve...@gmail.com

unread,
Mar 30, 2015, 8:36:33 AM3/30/15
to rav...@googlegroups.com
Hi , 

Thanks for that. Actually title.replace("foo","bar")  , replaces first instance of the occurrence only , it is not replaced with subsequent to remaining instance.

Example : I have "foo " more than 50 time in a document , but when I use above syntax it replace first "foo" with "bar" , but remaining "foo" are not replaced.

Do I need any additional syntax ? I tried with title.replaceall("foo","bar") , it didn't work.

Tal Weiss

unread,
Mar 30, 2015, 8:43:07 AM3/30/15
to rav...@googlegroups.com
you can write whatever javascript code is needed i'm sure you can find online the correct method for you.
you can add it to the saved functions and reuse it in many of your scripts

On Mon, Mar 30, 2015 at 3:36 PM, <mcpdeve...@gmail.com> wrote:
Hi , 

Thanks for that. Actually title.replace("foo","bar")  , replaces first instance of the occurrence only , it is not replaced with subsequent to remaining instance.

Example : I have "foo " more than 50 time in a document , but when I use above syntax it replace first "foo" with "bar" , but remaining "foo" are not replaced.

Do I need any additional syntax ? I tried with title.replaceall("foo","bar") , it didn't work.

On Friday, March 27, 2015 at 10:46:39 PM UTC+5:30, Tal Weiss wrote:

The best way is through the studio since it has tools to test your script. Notice that the documents button is actually a combo box click the down arrow choose patch then choose collection insert your script lets say you have a field name title than you write this.title = title.replace("foo", "bar")
(

On Mar 27, 2015 7:45 PM, <mcpdeve...@gmail.com> wrote:

Hi ,

I have tons of thousands in collection. I would like to replace a word with another word for all tons of document collection.

Is possible to update those with patch collection ? If yes , how to do it ?

--
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.

--
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.



--

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

Tal Weiss l Core Team Developer Mobile:+972-54-802-4849

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

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

Reply all
Reply to author
Forward
0 new messages