Closed Mihailoff closed 10 years ago
Hey @Mihailoff!
setAll is already present in SpahQL. Here's the source from src/SpahQL.js:
/**
* SpahQL#setAll(key, value) -> SpahQL
* - key (String, Number): The key to set on this result
* - value: The value to set for the given key
* SpahQL#setAll(dictionary) -> SpahQL
* - dictionary (Object): A key/value hash containing multiple keys to be set.
*
* Just like #set, only it attempts to set the given key(s) on all items in this set:
*
* db.select("//foo").set("a", "a-value") // Attempt to set "a" on all "foo" objects
*
* Just like #set, returns self.
**/
"setAll": function(keyOrDict, value) {
for(var i=0; i<this.length; i++) this.set(keyOrDict, value, this[i]);
return this;
},
Now i have to process paths in loop to modify every item.