I'm using mongoDb in my project, and I have problem using lookup on embedded data.. I searched for my problem and read similar codes.. but they didn't help my problem..
I mean in my embed document there is a variable named user
that I want to load its data by lookup..
this is how my documents is:
"_id" : ObjectId("5d0f6a993702da22bc00474d"),
"quotes" : [
{
"amount" : NumberInt(100),
"user" : {
"_id" : ObjectId("5cc69f7f46ab4cedda5c3c12")
},
"details" : "some quote details",
"_id" : ObjectId("5d0f6a993702da22bc00474c"),
"status" : "a"
},
{
"amount" : NumberInt(120),
"user" : {
"_id" : ObjectId("5cc69kij46ab4cedda5c3c12")
},
"details" : "some quote details 2",
"_id" : ObjectId("5d0f6a993702da22bc00484k"),
"status" : "a"
}
],
"status" : "Approved",
"title" : "gardening",
"created_at" : NumberInt(1560841417)
so I want my output be like this:
"_id" : ObjectId("5d0f6a993702da22bc00474d"),
"quotes" : [
{
"amount" : NumberInt(100),
"user" : {
"_id" : ObjectId("5cc69f7f46ab4cedda5c3c12"),
"firstName": "John",
"lastNAme": "Doe",
"phone": 514298742
},
"details" : "some quote details",
"_id" : ObjectId("5d0f6a993702da22bc00474c"),
"status" : "a"
},
{
"amount" : NumberInt(120),
"user" : {
"_id" : ObjectId("5cc69kij46ab4cedda5c3c12")
"firstName": "Jane",
"lastNAme": "Doe",
"phone": 5148547642
},
"details" : "some quote details 2",
"_id" : ObjectId("5d0f6a993702da22bc00484k"),
"status" : "a"
}
],
"status" : "Approved",
"title" : "gardening",
"created_at" : NumberInt(1560841417)