added getObjectsFields methods to db class, changed getUsers methods to use the new method, refactor to user.js and mongo.js

This commit is contained in:
barisusakli
2014-03-11 03:39:41 -04:00
parent 8873963946
commit 3d68c7c6b6
8 changed files with 244 additions and 247 deletions

View File

@@ -230,7 +230,7 @@ SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
}
var max = 5; //hardcoded
var usernames = "";
var finalText = "";
var pid_uids = data[0];
var rest_amount = 0;
@@ -240,15 +240,15 @@ SocketPosts.getFavouritedUsers = function(socket, pid, callback) {
pid_uids = pid_uids.slice(0, max);
}
user.getUsernamesByUids(pid_uids, function(err, result) {
user.getUsernamesByUids(pid_uids, function(err, usernames) {
if(err) {
return callback(err);
}
usernames = result.join(', ') + (rest_amount > 0
finalText = usernames.join(', ') + (rest_amount > 0
? " and " + rest_amount + (rest_amount > 1 ? " others" : " other")
: "");
callback(null, usernames);
callback(null, finalText);
});
});
};