dersar00
Hello!
Git Repository here.
I have a problem with saving data to database. I use mongodb_ecto adapter, when I try save it through iex console I can do it:
iex(1)> Friends.PersonController.save()
START SAVING
SAVED
09:58:17.706 [debug] QUERY OK db=0.4ms
INSERT coll="people" document=[age: 11, _id: #BSON.ObjectId<5b027c190d1a8f0f042d5600>] []
:ok
or
iex(1)> person = %Friends.Person{}
%Friends.Person{
__meta__: #Ecto.Schema.Metadata<:built, "people">,
age: nil,
first_name: nil,
id: nil,
last_name: nil
}
iex(2)> Friends.Repo.insert(person)
10:50:43.451 [debug] QUERY OK db=0.4ms
INSERT coll="people" document=[_id: #BSON.ObjectId<5b0288630d1a8f06ef2e3699>] []
{:ok,
%Friends.Person{
__meta__: #Ecto.Schema.Metadata<:loaded, "people">,
age: nil,
first_name: nil,
id: "5b0288630d1a8f06ef2e3699",
last_name: nil
}}
But if uncomment Friends.PersonController.save and try to call it when program is work, I got error:
⇒ mix
Compiling 1 file (.ex)
START SAVING
== Compilation error in file lib/friends.ex ==
** (ArgumentError) argument error
(stdlib) :ets.lookup_element(Mongo.IdServer, :machineprocid, 2)
lib/mongo/id_server.ex:50: Mongo.IdServer.new/0
lib/ecto/repo/schema.ex:651: Ecto.Repo.Schema.autogenerate_id/4
lib/ecto/repo/schema.ex:199: anonymous fn/13 in Ecto.Repo.Schema.do_insert/4
lib/friends/person_controller.ex:11: Friends.PersonController.save/0
lib/friends.ex:4: (module)
What’s the solution for it? How I can do it?
I have an assumption that when I run the program, I just do not start Mongo?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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 16 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dersar00
Thanks @Nicd! Good luck!
Nicd
That works on its own but not in a project where you have other applications that need starting up. In addition, the example in the documentation deals with
exs(script mode) files, which are run like scripts. Normally yourexfiles are compiled first and then executed.You need to look at how Elixir projects are started using a supervision tree. Unfortunately I’m quite busy right now so I can’t link any tutorial but I hope others can help in this regard. Basically what you want is a supervision tree that starts the necessary applications (like your Ecto.Repo), then starts a process with that RabbitMQ listener code.
dersar00
I made everything like in
rabbitmq elixirdocumentation.Part where is a full
receive.exsfile contentSo I did not admit that the problem could be there and looked for it everywhere, but not there
Nicd
The code at the end of the file (outside the
defmodule) is again run at compile time. I suggest you read up on how Elixir programs are started as to where you should put your code. You cannot put code just anywhere, because at compile time your applications are not running.dersar00
I publish a rabbitmq branch. U can see it in my repository
dersar00
I’m running it with mix
After my program start listen queue and stay active by that time I send to queue message from
rabbitmqmanagment console.Nicd
Have you started the Ecto application and your repos when running that? How are you running it? I can’t see it in your git repo. It seems you may have a misunderstanding of how Elixir applications are started.
dersar00
For example my main file looks like here.
Nicd
Where? We need more details.
dersar00
I call it, but I get the same error.