Closed katpavan closed 3 years ago
Issue solved:
Repo.insert_all fixed my issue.
One problem with insert_all is that inserted_at and updated_at don't get set, so you have to manually set that.
you can get the current timestamp by doing
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
INSERT INTO messages (message) VALUES ('one message'), ('two message'), ('three message')
I have a phoenix app where I scaffolded messages. I want to be able to insert multiple messages at the same time.
Right now i'm using a transaction to insert multiple messages into the database but I want to do this more efficiently.