New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Document with Relation Requires All Parent Fields Instead of Just ID #310
Comments
Hey. |
Glad you are back! |
Please try |
Thank you very much! I think we can call this one resolved. I'm able to {
"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:
|
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).The text was updated successfully, but these errors were encountered: