Closed hd10180 closed 1 year ago
Thank you for the issue.
Here is the full-working example with find_one
:
import asyncio
from motor.motor_asyncio import AsyncIOMotorClient
from beanie import Document, init_beanie
class UserEntity(Document):
username: str
async def main():
cli = AsyncIOMotorClient("mongodb://test:test@localhost:27017")
db = cli["test_find_one"]
await init_beanie(db, document_models=[UserEntity])
await UserEntity(username="JohnDoe").insert()
user = await UserEntity.find_one(UserEntity.username == "JohnDoe")
print(user)
# id=ObjectId('63721443e8e4e6cc80fba311') revision_id=None username='JohnDoe'
asyncio.run(main())
You probably use the Collection
inner class which is not supported since 1.15
, please use Settings
instead, if so.
I'll fix the GH releases, thank you!
thanks
Describe the bug i use conda install latest beanie(1.15.3) and i found my code went wrong. after i defined my model, i use model.find_one and i always get None return, it seems like find_one is broken @roman-right
To Reproduce
Expected behavior return an userEntity
Additional context after i reinstall beanie=1.13.0, all the things work by the way, beanie's release version on github went confuse, from 1.15.1 to 0.15.3
thanks your work.