You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feel free to ignore if you already solved the issue, but I'm leaving the reference in case someone ends up here in the future.
By default, ODMantic generates an id field itself for every Model. You can see the details here on why it does that.. This is the reason why you're getting an error: ODMantic is trying generate an implicit id field for your Catalog model but it already exists (i.e. defined by you in the model).
To use the id field (or, really, any name for the field you want your primary field to be), you have to do this:
from odmantic import Field, Model
class Catalog(Model):
id: str = Field(primary_field=True)
parent: Optional[str]
Hi cool library.
I have a question, perhaps a stupid one.
How to make your own string values id?
I want nice to get such a tree structure.
https://docs.mongodb.com/manual/tutorial/model-tree-structures-with-parent-references/
The text was updated successfully, but these errors were encountered: