I am experimenting with the $lookup operator in mongoDB and I am stuck.
I created two collections in the db: states and counties.
State collection: 1 document
state: “Texas”,
abbrev: “TX”
County collection: 1 document
county: “Dallas”,
state_id: _id of Texas document in state collection
I am referencing the state in the county collection with the state’s id.
When I try to configure the $lookup in Compass no embedded documents show up.
But if I just enter ‘string’ for localField and foreignField, it shows the embedded document.
I’m confused. Can anyone shed light?