fastapi-crudrouter icon indicating copy to clipboard operation
fastapi-crudrouter copied to clipboard

Mongo Support

Open timwford opened this issue 4 years ago • 19 comments
trafficstars

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

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

timwford avatar Feb 27 '21 02:02 timwford

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 avatar Feb 27 '21 08:02 awtkns

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

Testing mongo could be done with docker potentially

awtkns avatar Feb 27 '21 08:02 awtkns

+1 for motor and pydantic instead of odmantic

n0nvme avatar Jul 22 '21 14:07 n0nvme

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

tclasen avatar Dec 04 '21 19:12 tclasen

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

tclasen avatar Dec 04 '21 19:12 tclasen

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?

michele-tasca avatar Mar 31 '22 13:03 michele-tasca

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.

tclasen avatar Mar 31 '22 14:03 tclasen

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

michele-tasca avatar Apr 07 '22 21:04 michele-tasca

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

dclimber avatar May 19 '22 09:05 dclimber

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

dclimber avatar May 25 '22 08:05 dclimber

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 avatar May 25 '22 14:05 tclasen

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

dclimber avatar May 26 '22 05:05 dclimber

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 avatar Jun 15 '22 10:06 micoloth

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

dclimber avatar Jun 25 '22 06:06 dclimber

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 avatar Jun 25 '22 09:06 micoloth

@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

dclimber avatar Jul 03 '22 04:07 dclimber

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

gegnew avatar Jan 19 '23 17:01 gegnew

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

dclimber avatar Jan 19 '23 17:01 dclimber

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

PierroD avatar Apr 11 '23 10:04 PierroD