Closed wizardone closed 2 years ago
@wizardone I'm so sorry for the slow reply! I think this might be solved by changing MyApp.Repo
to MyApp.Repo.pool()
I forget when that got changed, but we clearly need to update it in our docs. I'm going to close it for now b/c I'm pretty sure that's the problem, but please let me know if this isn't it. I'll try to reply sooner next time!
@wizardone Just added a fix to the Readme which hopefully clarifies this:
If you're using Mongo with the MongoDB Ecto library, where you have it defined in your config/runtime.exs like this:
config :my_app, MyApp.Repo,
url: "mongo connection url"
You'll want to do reference mongo like this:
Mongo.find(MyApp.Repo.pool(), collection, %{_id: %{"$in" =>"some_ids"}})
@scottmessinger Thank you for answering. I'm afraid I don't fully remember what the problem was, but I'm pretty sure that I had to specify the pool
somewhere, so it was probably that. Good on updating the docs 👍
I'm working on a project, which I inherited. Under the supervision tree mongo ecto is started:
The repo config looks like this:
AFAIK within the project all interactions with the Repo work just fine:
works just fine, however there are also several calls to the db, using
Mongo
directly, e.g.:These seem to result in an exception, irrespective of the type of operation performed:
I've verified that mongo and mongo_ecto are working. Starting a manual Mongo process with
and then trying the same query (but passing in the newly created connection, not the repo)
results in a normal response with no errors. Any ideas as to why this was happening? Also worth noting that this started happening after upgrading mongo and mongo_ecto to the latest
beta
releases.