Hi I have User Schema like this:-
var userSchema = new Schema({
name: {type: String, default: null},
location: {
type: { type: String },
coordinates: [Number],
},
sentFriendRequests: [
{type: Schema.Types.ObjectId, ref: 'user'}],
receivedFriendRequests: [
{type: Schema.Types.ObjectId, ref: 'user'}]
});
It is working good for all the requirements. I am searching nearby users with this query:-
User.aggregate(
[{
$geoNear: {
near: { type: "Point", coordinates: [ longitude , latitude ] },
distanceField: "dist.calculated",
num: 5,
spherical: true
}
}], function(err, nearByUsers){
console.log(nearByUsers);
})
The above query is working very good But now i want to search only the users who are not my in my friends array and not in both sent and received friend request array.