Skip to content

Added support for reference and SubFrame mappings in $sub projections

Compare
Choose a tag to compare
@anthonyjb anthonyjb released this 06 Jul 20:19
· 89 commits to master since this release

This makes the following project possible:

web_order = WebOrder.one(Q._id == ObjectID(...), projection={
        'items': {
            '$sub': Item,
            'product': {
                '$ref': Product,
                'name': True 
            }
        }
    })

In the example above we select a single web order (Frame) and map all items for the order to an item (SubFrame). Each item has a reference to a product (Frame) which we select limiting the projection to just the product's name.