Make the javascript code more redeable

This commit is contained in:
Las Zenow 2013-06-01 00:16:04 +02:00
parent ca0b25a274
commit d8e46419b1

View file

@ -208,14 +208,16 @@ func (d *DB) updateTags() error {
}
var mr mgo.MapReduce
mr.Map = "function() { " +
"if (this.active) { this.subject.forEach(function(s) { emit(s, 1); }); }" +
"}"
mr.Reduce = "function(tag, vals) { " +
"var count = 0;" +
"vals.forEach(function() { count += 1; });" +
"return count;" +
"}"
mr.Map = `function() {
if (this.active) {
this.subject.forEach(function(s) { emit(s, 1); });
}
}`
mr.Reduce = `function(tag, vals) {
var count = 0;
vals.forEach(function() { count += 1; });
return count;
}`
mr.Out = bson.M{"replace": TAGS_COLL}
_, err = d.books.Find(bson.M{"active": true}).MapReduce(&mr, nil)
if err != nil {