You have two choices:

1) Make a model that contains a subdocument.
In this case the whole document is stored within the other document as a
subdocument.
The subdocument can be of type ming.schema.Document (
https://ming.readthedocs.io/en/latest/api/ming.schema.html?highlight=Dictionary#ming.schema.Document
) or a subclass of it. This in fact It's nearly the same as having two
different models, but the submodel doesn't exist by itself, only as a part
of the primary model.
See
https://ming.readthedocs.io/en/latest/userguide.html#working-with-subdocuments
for subdocument examples.

2) Make a model that relates to another model.
In this case the two models are stored in separate collections and each one
of them has a separate document.
One of the two models will keep a reference to the other one (through the
_id) and will query for the other one when the related attribute is
accessed.
This is done through the relations:
https://ming.readthedocs.io/en/latest/userguide.html#relating-classes

On Mon, Aug 20, 2018 at 8:30 AM Benjamin SOULAS <[email protected]>
wrote:

> Hi every one,
>
> I have a quick question: Is it possible to insert in only one document a
> model which contains several differents objects (in attribute wich contains
> only one object, or an attribute which contains a list of objects)?
> I ask because I would like to develop an API with MOngoDB as database, but
> in need to know if I can insert Models in only one document.
>
> Kind regards,
>
> Benjamin
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/turbogears.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to