Closed
Description
Sorry for posting this issue here but it's urgent :
I need help for creating an complexe query:
First here's a schema for my db :
-
The
friends
model represent the friendship between two users. -
Each
user
has acity
What I'm trying to achieve is to create function that take an userId
as input and return list of cities Sorted by number of friends.
Here's my code until now
function getCities(userId) {
//This query allow to count number of friends in a given city
var innerQuery1 = new Parse.Query(Friends);
innerQuery1. equalTo("user1", userId);
var innerQuery2 = new Parse.Query(Friends);
innerQuery2.equalTo("user2", userId);
countFriendsQueryInCity = Parse.Query.or(innerQuery1, innerQuery2);
countFriendsQueryInCity.equalTo("city", cityId)
countFriendsQueryInCity.count({..})
//This to get all cities
var query = new Parse.Query(City);
//Sort this query using the first one
query.find({})
}
So the probleme is I can't figure a way way in parse or mongodb to join the two queries ?
Metadata
Metadata
Assignees
Labels
No labels