Created
February 18, 2013 18:30
-
-
Save shinecita/4979521 to your computer and use it in GitHub Desktop.
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
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