Skip to content

Instantly share code, notes, and snippets.

@shinecita
Created February 18, 2013 18:30
Show Gist options
  • Save shinecita/4979521 to your computer and use it in GitHub Desktop.
Save shinecita/4979521 to your computer and use it in GitHub Desktop.
User.similar = function(user, done) {
User
.find({
_id: {$ne: user._id},
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(user){return user.name}));
users = users.filter(function(user) {return user.name != ""});
console.log("filtered users",users.map(function(user){return user.name}));
}
done(err, users);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment