cortfritz
I’m working on a project that uses :mongodb_driver (GitHub - zookzook/elixir-mongodb-driver: MongoDB driver for Elixir · GitHub). 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 · GitHub 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.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 8- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
cortfritz
[
,
]
al2o3cr
FWIW, there’s already a PR that claims to switch
mongodb_ectoto usemongodb_driverfrom January:https://github.com/elixir-mongo/mongodb_ecto/pull/190
However, I agree with your assessment that the
extrakey will cause problems - particularly inMongo.Ecto.Connection.format_querywhere every head expects aMongo.Queryto have that key:https://github.com/elixir-mongo/mongodb_ecto/blob/83587c2c5d14f5956ad78ffaba62630515e44e06/lib/mongo_ecto/connection.ex#L477-L484
cortfritz
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.rhcarvalho
I tried using
:mongodb_ectofor 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.
cortfritz
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.
cortfritz
For example phx.gen.live
rhcarvalho
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?
cortfritz
haven’t considered that! Considering now, thank you.