In Ruby, we usually write User#email
to refer to the email column in the users table. I was wondering if there is an equivalent for Ecto.schema. Is it just %User{}.email
?
1 Like
Hi, you normally load data with ecto and assign it to a variable. Then you use the variable to access the columns.
user = Repo.get!(User, id)
Then…
user.name
user.address
Sorry that wasn’t what I meant. The context for me is when writing a commit message. In Ruby, my commit message would look something like
Add `User#email`.
In Ecto, results are returned as a struct so I wasn’t sure how I would type that in a commit message.
Add `%User.email`?
Personally I’d spell it out as “add email to User schema”. Especially since this enables you to differ easily between schemas and regular structs.
5 Likes