[英]Query/Find MongoDB documents with series of multiple conditions
我有一个用户架构,其中的基本字段包括兴趣,位置坐标,我需要使用特定的UserId来执行POST请求以获得结果
app.post('api/users/search/:id',function(err,docs) { //find all the documents whose search is enabled. //on documents returned in above find the documents who have atleast 3 common interests(req.body.interests) with the user with ':id' // -----OR----- //find the documents who stay within 'req.body.distance' compared to location of user with':id' //Something like this return User .find({isBuddyEnabled:true}), .find({"interests":{"$all":req.body.interests}}), .find({"_id":req.params.id},geoLib.distance([[req.body.gcordinates],[])) });
基本上我需要执行内部查找或查询内部查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.