By using a common
module (we can name it whatever we want), we make dependencies explicit, reduce unnecessary documentation, and avoid polluting the global namespace.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var acl = require('../routes/middleware/acl'); | |
var mongoose = require('mongoose'); | |
// var config = require('../libs/configurator'); don't need this | |
var config = require('../libs/configurator'); | |
var async = require('async'); | |
require('../models')(mongoose); | |
// mongoose.models.Works.find({}).exec(function (err, works) { <-- Work should be singular, as in below | |
mongoose.models.Work.find({}).exec(function (err, works) { | |
async.each(works, function (work, cb) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map = function() { | |
return this.tagsL.forEach(function(tagL, i) { | |
return emit(tagL, 1); | |
}); | |
}; | |
reduce = function(k, vals) { | |
print (k) | |
print (vals) | |
return vals.length; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diffArray = (a, b, done) -> | |
u = {}; | |
diff = | |
a: [] | |
b: [] | |
async.forEach b, (x, cb) -> | |
u[x] = true | |
cb() | |
, (err) -> | |
async.forEach a, (x, cb) -> |