mongodb_ecto
mongodb_ecto copied to clipboard
Switch underlying driver to mongodb_driver for MongoDB 6.0+ support
This PR switches the adapter over to https://github.com/zookzook/elixir-mongodb-driver .
~~Currently, the mix.exs/mix.lock file is pointed at our fork at https://github.com/hundio/elixir-mongodb-driver until a Hex release is made with the required adapter compatibility changes.~~ The mix.exs file now points to mongodb_driver 1.4.0, rather than our own repository.
Upgrading from one driver to the other is fairly transparent for users of the Ecto adapter (unless direct calls to the driver are made outside the adapter):
- Some Repo module config options are no longer used and can be simply deleted:
pool
,pool_overflow
,pool_timeout
. - If an application makes calls to the driver directly, then some modifications are required when using the new driver:
- The
pool
option is no longer accepted byMongo
database command functions - Any command function called from the
Mongo
module cannot be passed aPool
module from the Repo any longer; instead, a pool PID is expected:
- The
alias MyApp.Repo
# Old driver call
Mongo.find(Repo.Pool, "my_coll", %{"id": id}, projection: %{"field": 1}, pool: db_pool())
# New driver call
Mongo.find(Repo.pool(), "my_coll", %{"id": id}, projection: %{"field": 1})
# repo.ex
# Provided the following function is defined in MyApp.Repo:
defmodule MyApp.Repo do
use Ecto.Repo, otp_app: :my_app, adapter: Mongo.Ecto
def pool() do
Ecto.Adapter.lookup_meta(__MODULE__).pid
end
end
Thanks so much, @brennana! I'm excited to review this. In looking over the commits, it seems like there's shockingly little to change. Exciting!
The MongoDB driver 1.4.0 contains the changes needed for this PR.
Thank you @zookzook!