[beanie] Custom collection name for beanie Document models.
Contents
The following beanie model will result in documents being saved into a MongoDB collection named Person
. What if we want our collection to be named people
?
|
Beanie provides a mechanism to deal with this exact case.
Adding a Collection
inner class, the name attribute tells beanie to use an alternative collection name.
|
In this next example, our model is named Vehicle
but the Mongodb collection will be cars
.
|
About beanie
Beanie - is an Asynchronous Python object-document mapper (ODM) for MongoDB, based on Motor and Pydantic.