TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Junaid Syed
NA
485
130.5k
How to join 2 collections based on ID's
Jun 25 2018 1:23 AM
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
Reply
Answers (
1
)
Netbeast router URL is missing or device cannot be found.
Microsoft Graph API to receive mails