mongodb - MotorEngine - How to represent the equivalent of the foreign key in model? -
in mongodb have document represents balance has stakeholder's id field.
i need relate these 2 classes, balance , stakeholder, don't know what's proper way. i've seen there's field appropiate still don't understand it: embeddeddocumentfield()
class balance(document): id = uuidfield() creation_date = datetimefield(auto_now_on_insert=true) gross_balance = floatfield(required=true, min_value=0, default=0) balances_description = stringfield(required=true, max_length=255) stake_holder = #fk stakeholder class stakeholder(document): ...
any idea?
if stakeholder represents document other collection , stake_holder
objectid, should use referencefield()
stake_holder = referencefield(reference_document_type=stakeholder)
Comments
Post a Comment