awtkns / fastapi-crudrouter

A dynamic FastAPI router that automatically creates CRUD routes for your models
https://fastapi-crudrouter.awtkns.com
MIT License
1.37k stars 155 forks source link

Mongo Support #32

Open timwford opened 3 years ago

timwford commented 3 years ago

Probably use ODMantic: https://github.com/art049/odmantic

How would you test the implementation? mock a mongo db?

awtkns commented 3 years ago

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.

awtkns commented 3 years ago

How would you test the implementation? mock a mongo db?

Testing mongo could be done with docker potentially

n0nvme commented 3 years ago

+1 for motor and pydantic instead of odmantic

tclasen commented 2 years ago

Hello! I'm resurrecting this thread to recommend https://roman-right.github.io/beanie/ as the ODM for this ticket.

tclasen commented 2 years ago

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

michele-tasca commented 2 years ago

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?

tclasen commented 2 years ago

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.

michele-tasca commented 2 years ago

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..

dclimber commented 2 years ago

@tclasen where can one find the fork? Could you please send the link?

dclimber commented 2 years ago

It is indeed possible to make it work with Beanie — working on it.

tclasen commented 2 years ago

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.

dclimber commented 2 years ago

@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 :)

micoloth commented 2 years ago

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

dclimber commented 2 years ago

@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.

micoloth commented 2 years ago

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?

dclimber commented 2 years ago

@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

gegnew commented 1 year ago

What's the status here? Any chance these PRs get merged?

dclimber commented 1 year ago

@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 :)

PierroD commented 1 year ago

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