Skip to content

Instantly share code, notes, and snippets.

@danared
Created November 2, 2015 18:09
Show Gist options
  • Save danared/b3768beda195f69dc818 to your computer and use it in GitHub Desktop.
Save danared/b3768beda195f69dc818 to your computer and use it in GitHub Desktop.
db.homeSales.aggregate([
{$match: {
amount: {$gte:3000000}}
},
{$lookup: {
from: "postcodes",
localField: "address.postcode",
foreignField: "postcode",
as: "postcode_docs"}
},
{$project: {
_id: 0,
saleDate: "$date",
price: "$amount",
address: 1,
location: "$postcode_docs.location"}},
{$sort:
{
price: -1
}}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment