2017-05-09 33 views
0

案例:當產生新的開發環境時,我想通過一些集合並更改某些字符串值中的TLD,例如「bla bla mydomain.com」變成「bla bla mydomain.localhost」是否可以在RavenDB javascript-patches中進行字符串替換?

我在補丁窗口只是試圖掠奪演播室:

this.MyProperty = this.MyProperty.replace(".com", ".localhost"); 

但我得到:

TypeError: Property 'replace' of object is not a function

之後,我去了the docs,那裏的確似乎串更換不是一種選擇。

我的問題是:是否有可能以任何方式在RavenDB中的js-patches中進行字符串替換?

回答

0

啊 - 發現在5分鐘後:

_.replace(this.MyProperty, ".com", ".localhost"); 

由於docs say,強調_引用lodash library(包括hashtag RTFM)

+0

lodash作品。但是,.replace也可以。我猜你只需要做一個空或未定義的檢查,例如if(this.Name){this.Name.replace(...)} –

相關問題