dersar00

dersar00

Error with saving to mongo db

Hello!
Like a mongodb driver for elixir I using Mongo.Ecto.

When I try to save something using using command insert:

of = %Friends.Person{age: 44}
Friends.Repo.insert(of)

I got error:

** (exit) exited in: GenServer.call(Friends.Repo.Pool, :topology, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir) lib/gen_server.ex:824: GenServer.call/3
    (mongodb) lib/mongo.ex:750: Mongo.select_servers/4
    (mongodb) lib/mongo.ex:727: Mongo.select_server/3
    (mongodb) lib/mongo.ex:501: Mongo.insert_one/4
    (mongodb_ecto) lib/mongo_ecto/connection.ex:120: Mongo.Ecto.Connection.insert/3
    (mongodb_ecto) lib/mongo_ecto.ex:630: Mongo.Ecto.insert/6
    (ecto) lib/ecto/repo/schema.ex:469: Ecto.Repo.Schema.apply/4
    (ecto) lib/ecto/repo/schema.ex:205: anonymous fn/13 in Ecto.Repo.Schema.do_insert/4

I did everything as in a guide: https://hexdocs.pm/ecto/getting-started.html

Most Liked

idi527

idi527

Could you please make a small repo on github with the code to reproduce this? That would help us identify the problem on our own machines and then walk you through a (hopefully) solution.

NobbZ

NobbZ

What does your mixfiles application function look like?

Is it (close to) the following?

def application do
  [mod: {Friends.Application, []}]
end
idi527

idi527

As @NobbZ suggested, you need to add your application to your application function in mix.exs (https://github.com/dersar00/friends/blob/master/mix.exs#L15-L20), otherwise it won’t be started.

Try replacing

  def application do
    [
      # NOTE: I think you should use either :extra_applications or :applications
      # see https://www.amberbit.com/blog/2017/9/22/elixir-applications-vs-extra_applications-guide/
      applications: [:method_missing, :logger, :mongodb_ecto, :ecto],
      extra_applications: [:logger]
    ]
  end

with

def application do
  [
    mod: {Friends.Application, []}, # points to the module with application
    extra_applications: [:logger]
  ]
end
idi527

idi527

What version of ecto are you using? It might be outdated.

Try replacing

  def start(_type, _args) do
    # List all child processes to be supervised
    children = [
      Friends.Repo
      # {Friends.Worker, arg},
    ]

with

def start(_type, _args) do
  import Supervisor.Spec

  # List all child processes to be supervised
  children = [
    supervisor(Friends.Repo, [])
    # {Friends.Worker, arg},
  ]

in https://github.com/dersar00/friends/blob/master/lib/friends/application.ex#L11

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New

We're in Beta

About us Mission Statement