Skip to content

Support for $ref_key

Choose a tag to compare

@anthonyjb anthonyjb released this 17 Apr 19:46
· 1 commit to master since this release

This release adds support for specifying a foreign key field other than the _id field when using $ref (references) in projections. To specify a different foreign key you can now use $ref_key like so:

employees = Employee.many(
    projection={
        'first_name': True,
        'company': {
            '$ref': Company,
            '$ref_key': 'company_no',
            'name': True
        }
    }
)