Hi iam trying to join 2 collections based on parameters I need to pass Property ID as parameter and get that perticular property details from property collection but iam getting whole data from 2 collections.So how can i pass parameter in the aggregate joins in Node js
my code is some thing like this
- exports.sample = function(req, res){
- var input = req.body;
- var newValues = {UserID:input.UserID,IsFavorite:input.IsFavorite,PropertyId:input.PropertyId}
- console.log(input);
- MongoClient.connect(url, function(err, db){
- if (err) throw err;
- var dbo = db.db("abc");
- dbo.collection('CLC_Isfavorite').aggregate([
- {
- $lookup:
- {
- from: 'CLC_Property',
- localField:'PropertyId',
- foreignField:'PropertyId',
- as:'propertyfavorites'
- }
- }
- ]).toArray(function(err,result){
- if (err) throw err;
- console.log(JSON.stringify(result))
- res.json({status : 'success', message : 'Records found', result : result});
- db.close();
- })
- });
- }
In the above code i need to get property details based on property id which i pass where can i define the parameter property id in above code.Can anyone suggest me any idea thank you in advance