Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- db.inspections.aggregate([
- {$match :
- {"VIOLATION CODE": {$eq: "04L"}}
- },
- {$lookup :
- {
- from : "restaurants",
- localField : "NAME",
- foreignField : "name",
- as : "restaurants"
- }
- },
- {
- $unwind : "$restaurants"
- },
- {
- $addFields: {
- "isMatchingZip": { $cmp: [ "$restaurants.address.zipcode", "$ZIPCODE" ] }
- }
- },
- { $match :
- { "isMatchingZip": 0 }
- },
- {$lookup :
- {
- from : "demographics",
- localField : "restaurants.address.zipcode",
- foreignField : "JURISDICTION NAME",
- as : "demographics"
- }
- },
- {
- $unwind : "$demographics"
- },
- {$match :
- {"demographics.PERCENT FEMALE": {$eq: "0.5"}}
- }
- ]).pretty()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement