Mongodb(via MongoEngine) join query with aggregate

2017-01-09
Since Mongodb 3.2 and MongoEngine 0.9, we can use $aggregate command to perform join queries on multiple collections in a database. This post would be a simple tutorial for join queries on Mongodb(via MongoEngine in Python) with examples. Models Setup Let’s consider models defined as below: import random import mongoengine class User(mongoengine.Document): meta = {"indexes": ['rnd']} name = mongoengine.StringField() rnd = mongoengine.FloatField(default=random.random) class Group(mongoengine.Document): meta = {"indexes": ['rnd']} name = mongoengine. Continue reading