Ecto Syntax Flashcards

1
Q

Repo.insert_all/3

A

MyRepo.insert_all(Post, [[title: “My first post”], [title: “My second post”]])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Repo.insert/2 with do block

A

case MyRepo.insert %Post{title: “Ecto is great”} do
{:ok, struct} -> # Inserted with success
{:error, changeset} -> # Something went wrong
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Repo.insert/2, no do block

A

{:ok, inserted} = MyRepo.insert(%Post{title: “this is unique”})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly