Closed rgajason closed 1 year ago
Hey. Thank you for the report. This is an important one. I'll pick it up asap
Glad you are back!
Please try 1.11.9
Thank you very much! I think we can call this one resolved. I'm able to POST
data such as:
{
"organization": "62de9ecf2fa3d30007e3b5ce",
"name": "beanie"
}
...and the document is successfully created as expected.
The auto-generated documentation doesn't reflect this, but I can easily override.
Thanks again!
Hi last time I start use benie odm, and I find it it great.
It is possible make relations like on sqlalchemy:
class ProductType(Base):
name = sa.Column(sa.String(255), nullable=False, default='')
dimension_id = sa.Column(sa.Integer,
sa.ForeignKey('dimension.id', ondelete='RESTRICT', name='fx_product_type_dimension'),
nullable=False)
dimension = relationship('Dimension', )
Thanks
The documentation seek is here: https://roman-right.github.io/beanie/tutorial/relations/
When used with FastAPI, all parent required fields become child required fields when creating a new document. For example:
Models
Routers
I can create an Organization by
POST
ing the following:Let's say that generated a Mongo object ID of
62de9ecf2fa3d30007e3b5ce
.However, I cannot create a Repository with just the following:
That results in 422, unprocessable entity, with details that the Organization SLUG is required. I have tried the a few variations -
id
,_id
, and also specifyingorganization
as a string (the ID) vs an object (dictionary) - all with the same 422 error and similar messages.Specifying any string for
slug
seems to work. For example:(
Repository
document created as expected with link to correctOrganization
document)It would seem to just be a parameter validating issue (required parent fields are required parameters even though only the
id
is used).