Has anyone gotten mogodb_ecto working with mongodb_driver?

I’m working on a project that uses :mongodb_driver (GitHub - zookzook/elixir-mongodb-driver: MongoDB driver for Elixir). I use Ecto changesets but not full ecto queries. I’d like to be able to use libraries that use Ecto so I am looking into adding full Ecto via :mongodb_ecto. :mongodb_driver README says it has supported Ecto since v1.4.0.

I picked this driver some time ago as the repo seemed more alive. This driver also provides watch_collection which allows my elixir service to respond to changes in mongo.

:mongdb_ecto seems typically to use :mongodb, a different driver.

:mongdb_ecto expects the struct Mongo.Query to have the key :extra. :mongodb has this key in that struct, :mongodb_driver does not.

I’m using current versions, and have tried combinations of older versions but have not found a combination where this works.

I’m considering forking :mongodb_ecto to handle this, on the presumption that whatever :extra is doing I can work around it or bypass it as I don’t need it. If I find something elegant I can offer PR. I’m also asking :mongodb_driver maintainers if I can contribute, in which case I’ll figure out what work :extra is doing and submit a PR that supports it.

Maybe someboy else has figured this out and I can do something similar to what they did and not have to do the above.

Alternatively, maybe somebody has a different idea altogether. I’m open. I’m even willing to discuss at length “why aren’t you just using Postgres” which I expect from this joyus community. I might even find a path to that less costly than anything else, and projects like GitHub - mathieuprog/polymorphic_embed: Polymorphic embeds in Ecto make this more tenable. But for now presume that I’d just like to learn how :mongodb_driver works with :mongodb_ecto, like I believe that it says it does.

[:cricket:, :cricket:]

FWIW, there’s already a PR that claims to switch mongodb_ecto to use mongodb_driver from January:

However, I agree with your assessment that the extra key will cause problems - particularly in Mongo.Ecto.Connection.format_query where every head expects a Mongo.Query to have that key:

Matt, thank you. It looks like that PR removes extra: from the Struct and comments out code that references that key or its value. Going to try it.

I tried using :mongodb_ecto for some time but reverted to using the zookzook driver directly. The driver can model collections, and I can create something like an ecto repo that starts up with the application.

I can still use Ecto.Changeset where it makes sense. I found this setup much more stable.

Yes j started with that.

But I want to use frameworks that depend on Ecto and generate queries with adapter- and so on. So I also want to get Ecto working.

For example phx.gen.live

I see. In my case I was dealing with multiple repos, SQL-based and MongoDB. Trying to use Ecto with mongo had so many caveats that I felt it was only getting in the way. I’d rather write MongoDB queries directly and have access to aggregation operations.

For this particular case, have you considered customizing the templates?

haven’t considered that! Considering now, thank you.