Skip to content

Instantly share code, notes, and snippets.

@shinecita
Created February 21, 2013 19:09
Show Gist options
  • Save shinecita/5007228 to your computer and use it in GitHub Desktop.
Save shinecita/5007228 to your computer and use it in GitHub Desktop.
User.getUntrackedSimilar = function(user, done) {
var excludeIds = user.similarTracked || [];
excludeIds.push(user._id);
User
.find({
_id: {$nin : excludeIds},
tags: {$in: user.tags},
name : {$exists : true, $ne : null, $ne : ""}
}, {limit: 5}, function(err, users) {
// Temporary fix for avoiding users with name :""
if (users) console.log("users", users.map(function(u){ return u._id}));
if (users) {
users = users.filter(function(user) {return (user.name != "" && user.name != null) });
}
done(err, users);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment