movies: {
_id: "1"
name: "comedy"
userratings: [{
user_id: "11",
count: 4
}, {
user_id: "22",
count: 2
}]
}
movies: {
_id: "2"
name: "funny"
userratings: [{
user_id: "22",
count: 8
}]
}
users: {
_id: "11",
name: "jhon",
userFriends: [{
user_id: "22"
}, {
user_id: "12"
}]
}
users: {
_id: "22",
name: "tom",
userFriends: [{
user_id: "11"
}]
}
I have two collections: users and movies. The users collection consists of users info and his friends list. The movies collection consists of movies info and the rating of users to the movie.
My question is: how I can find the movies that are rated by a user's friends but not the user,and order them by the sum of friends'ratings count, limit 5 records.
I am using java with mongodb