I hereby claim:
- I am komlanvi on github.
- I am komlanvi (https://keybase.io/komlanvi) on keybase.
- I have a public key ASDDPVJsNBQpP1KmdDcbOcI4H3NC5r7IOPFly4hhMahpsQo
To claim this, I am signing this object:
defmodule App.Schema.Product do | |
use Ecto.Schema | |
alias App.Repo # new line | |
# schema definition remain the same | |
def get_by_id(product_id) do | |
Repo.get(__MODULE__, product_id) | |
end | |
defmodule App.Schema.Product do | |
use Ecto.Schema | |
@primary_key {:id, :binary_id, autogenerate: true} | |
schema "products" do | |
field :name, :string | |
field :brand, :string | |
field :discounted, :boolean | |
field :expiration_date, :date | |
end |
defmodule App.Context do | |
# previous lines remain the same | |
def get_user_by_first_name_and_last_name(first_name, last_name) do | |
User | |
|> User.by_first_name(first_name) | |
|> User.by_last_name(last_name) | |
|> Repo.one() | |
end |
defmodule App.Context do | |
alias App.Repo | |
alias App.Schema.User | |
def get_user_by_first_name(first_name) do | |
User | |
|> User.by_first_name(first_name) | |
|> Repo.all() | |
end | |
defmodule App.Schema.User do | |
use Ecto.Schema | |
alias App.Repo | |
import Ecto.Query, only: [from: 2] # new line to import the from macro | |
# schema generation remain the same | |
def by_first_name(query \\ __MODULE__, first_name) do | |
from(u in query, where: u.first_name == ^first_name) | |
end |
defmodule App.Schema.User do | |
use Ecto.Schema | |
alias App.Repo # new line | |
# schema definition remain the same | |
def get_user_by_id(user_id) do | |
Repo.get(User, user_id) # here we use the get/2 function from the Repo module | |
end |
defmodule App.Schema.User do | |
use Ecto.Schema | |
@primary_key {:id, :binary_id, autogenerate: true} | |
schema "users" do | |
field :email, :string | |
field :first_name, :string | |
field :last_name, :string | |
field :age, :integer | |
field :online, :boolean |
I hereby claim:
To claim this, I am signing this object:
mkdir react-test | |
cd react-test | |
touch package.json |
Robot r1 = new Robot("Robert", 0, 0.71); | |
Robot r2 = new Robot("Roland", 0, 0.65); | |
Robot r3 = new Robot("Rodrigue", 0, 0.85); |