henryliangt / mongodb

0 stars 0 forks source link

Aggregate unwind group project - filter reduce - define function #6

Open henryliangt opened 2 years ago

henryliangt commented 2 years ago

3 collections in 1 database. climates, users, coords,

data source from climates.json climates.zip image

henryliangt commented 2 years ago

Query by Aggregate:

image

henryliangt commented 2 years ago

Query by aggregate

image

image

henryliangt commented 2 years ago

1663222245608

henryliangt commented 2 years ago

aaa

henryliangt commented 2 years ago

another dataset. 2 files users.json coords.json

data.zip

coords image

users image

henryliangt commented 2 years ago

image

db.getCollection("coords").aggregate( [ { $lookup: { from: 'users', localField:'city_id', foreignField: 'city_id', as: "city_ids" } }, { $match: { "$expr": {"$gt":["$latitude", 0]} }, },

]

);