当前位置: 动力学知识库 > 问答 > 编程问答 >

elixir - Batch insert with Ecto

问题描述:

I'm trying to insert 800 changesets using a multirow INSERT query with Ecto. I'm using postgres. I see that postgrex supports this now. Is it possible yet with Ecto?

I'm also open to doing this via prepared statement if that's possible.

网友答案:

Ecto 2.0 will support Repo.insert_all/3 (current latest version is 2.0.0-rc.4 which supports this), but it doesn't support inserting changesets, only raw Maps or Keyword lists, so you'll have to filter all valid changesets and extract the fields from them yourself like you would have needed to if you used the Postgrex bulk insert feature.

分享给朋友:
您可能感兴趣的文章:
随机阅读: