fastapi-crudrouter
fastapi-crudrouter copied to clipboard
Mongo Support
Probably use ODMantic: https://github.com/art049/odmantic
How would you test the implementation? mock a mongo db?
I agree. We should support mongo support mongo. I think it would be fairly easy with odmantic! Alternatively just the motor and pydantic could work.
How would you test the implementation? mock a mongo db?
Testing mongo could be done with docker potentially
+1 for motor and pydantic instead of odmantic
Hello! I'm resurrecting this thread to recommend https://roman-right.github.io/beanie/ as the ODM for this ticket.
Hello! I'm resurrecting this thread to recommend https://roman-right.github.io/beanie/ as the ODM for this ticket.
Also, there is now support for mocking out motor during unit tests that don't really need a full running mongodb: https://github.com/michaelkryukov/mongomock_motor
Hello everyone! Any news on this ?
Is this (using crudrouter with mongodb) currently possible in any way (even hacky), or is it just not supported?
I was able to get it working with Beanie in a fork, I just didn't finish out the typing to get it to pass mypy. It is very possible.
I could definitely use that fork!😁
If typing requires some work, I'd be happy to work on it if you want, so we can open a pull request.
Idk if this repo is still mantained, but the docs say the list of supported DBs is supposed to grow so..
@tclasen where can one find the fork? Could you please send the link?
It is indeed possible to make it work with Beanie — working on it.
Hey, @dclimber , sorry I missed your original tag. I'd happily assist you with building this out. Maybe even @killswitch-GUI would want to take a look at this as well.
@tclasen cool! I've made it work — the BeanieCRUDRouter, based it on OrmarCRUDRouter, as they have pydantic's BaseModel in common. Manual tests during 'experiments' succeeded.
Now I need to write the actual tests, and I guess it's ready :)
Hi guys! Are there news on this?
@dclimber A very rough draft would still be very useful for me at this moment!
I can contribute and finish working on it if needed
@micoloth I have it working with ODMantic, but need to adjust tests, so that they pass. I guess I can publish it into a branch
I have a branch with Beanie, it works, but tests need adjusting as well.
Thank you for your work!
Any of the two branches would be very helpful for me, yes!😌
I can certainly help to work on the tests if that's needed.
Maybe the code can be published as a branch specifying it's WIP work?
@micoloth hey, sorry for a late reply. Beanie branch: https://github.com/dclimber/fastapi-crudrouter/tree/feature/beanie ODMantic branch: https://github.com/dclimber/fastapi-crudrouter/tree/feature/odmantic
PR for Beanie: https://github.com/dclimber/fastapi-crudrouter/pull/1 PR for ODMantic: https://github.com/dclimber/fastapi-crudrouter/pull/2
What's the status here? Any chance these PRs get merged?
@gegnew I needed these features for a project, but it got cancelled, so I no longer work on these MRs. The only thing that is needed is unit tests.
Also there's an annoying id -> _id thing to fully solve.
If you're willing to help - feel free to fork and add some tests :)
UPD: Although, there's a chance I get back to it in the coming days, as there's another use case for it :)
Hello everyone,
I made a CRUDRouter for MongoDB, with the id -> '_id' and vice versa.
Feel free to read the doc and / or try it : https://github.com/PierroD/fastapi-crudrouter-mongodb