plasm v1.0.0 Plasm
Summary
Functions
Builds a query that finds all records at a specified date and time for a specified field name
Builds a query that finds all records at or before a specified date and time for a specified field name
Builds a query that finds all records at a specified date and time for a specified field name
Builds an average query for a given field
Builds a count query
Builds a distinct count query for a given field
Builds a distinct query for a given field
Builds a query that finds all records before a specified date or date and time for a specified field name
Builds a query that finds the first record after sorting by a specified field name ascending
Builds a query that finds all records matching any of the primary key values in the provided list or value
Builds a query that finds all records after a specified field name and date or date and time
Builds a query that finds the last record after sorting by a specified field name ascending
Builds a maximum query for a given field
Builds a minimum query for a given field
Builds a query that finds all records on a specified date for a specified field name
Builds a query that finds all records on or before a specified date for a specified field name
Builds a query that finds all records on or after a specified date for a specified field name
Builds a query that grabs a random record
Builds a sum query for a given field
Builds a query that finds all records matching all specified field names and values
Builds a query that finds all records matching none of the specified field names and values
Functions
Specs
at(Ecto.Queryable, atom, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
at(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records at a specified date and time for a specified field name.
Puppy |> Plasm.at(:updated_at, ecto_date_time) |> Repo.all
Puppy |> Plasm.at(:updated_at, "2014-04-17T14:00:00Z") |> Repo.all
Specs
at_or_earlier_than(Ecto.Queryable, atom, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
at_or_earlier_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records at or before a specified date and time for a specified field name.
Puppy |> Plasm.at_or_earlier_than(:updated_at, ecto_date_time) |> Repo.all
Puppy |> Plasm.at_or_earlier_than(:updated_at, "2014-04-17") |> Repo.all
Specs
at_or_later_than(Ecto.Queryable, atom, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
at_or_later_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records at a specified date and time for a specified field name.
Puppy |> Plasm.at_or_later_than(:updated_at, ecto_date_time) |> Repo.all
Puppy |> Plasm.at_or_later_than(:updated_at, "2014-04-17") |> Repo.all
Specs
average(Ecto.Queryable, String.t) :: Ecto.Queryable
average(Ecto.Queryable, atom) :: Ecto.Queryable
Builds an average query for a given field.
Puppy |> Plasm.average(:age) |> Repo.one
Puppy |> Plasm.average("age") |> Repo.one
Specs
count(Ecto.Queryable) :: Ecto.Queryable
Builds a count query.
Puppy |> Plasm.count |> Repo.one
Specs
count_distinct(Ecto.Queryable, String.t) :: Ecto.Queryable
count_distinct(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a distinct count query for a given field.
Puppy |> Plasm.count_distinct(:name) |> Repo.one
Puppy |> Plasm.count_distinct("age") |> Repo.one
Specs
distinct_by(Ecto.Queryable, String.t) :: Ecto.Queryable
distinct_by(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a distinct query for a given field.
Puppy |> Plasm.distinct_by(:age) |> Repo.all
Puppy |> Plasm.distinct_by("name") |> Repo.all
Specs
earlier_than(Ecto.Queryable, atom, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
earlier_than(Ecto.Queryable, atom, %Ecto.Date{day: term, month: term, year: term}) :: Ecto.Queryable
earlier_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records before a specified date or date and time for a specified field name.
Puppy |> Plasm.earlier_than(:updated_at, ecto_date_or_date_time) |> Repo.all
Puppy |> Plasm.earlier_than(:updated_at, "2014-04-17") |> Repo.all
Specs
earliest(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a query that finds the first record after sorting by a specified field name ascending.
Optionally, provide an integer n
to find only the first n
records.
Puppy |> Plasm.earliest(:inserted_at) |> Repo.one
Puppy |> Plasm.earliest(:inserted_at, 20) |> Repo.all
Specs
find(Ecto.Queryable, list) :: Ecto.Queryable
find(Ecto.Queryable, any) :: Ecto.Queryable
Builds a query that finds all records matching any of the primary key values in the provided list or value.
Puppy |> Plasm.find([1,2,3]) |> Repo.all
Puppy |> Plasm.find(10) |> Repo.one
Puppy |> Plasm.find("748192739812839") |> Repo.one
Specs
later_than(Ecto.Queryable, atom, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
later_than(Ecto.Queryable, atom, %Ecto.Date{day: term, month: term, year: term}) :: Ecto.Queryable
later_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records after a specified field name and date or date and time.
Puppy |> Plasm.later_than(ecto_date_or_date_time) |> Repo.all
Puppy |> Plasm.later_than("2014-04-17") |> Repo.all
Specs
latest(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a query that finds the last record after sorting by a specified field name ascending.
Optionally, provide an integer n
to find only the last n
records.
Puppy |> Plasm.latest(:inserted_at) |> Repo.one
Puppy |> Plasm.latest(:inserted_at, 20) |> Repo.all
Specs
maximum(Ecto.Queryable, String.t) :: Ecto.Queryable
maximum(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a maximum query for a given field.
Puppy |> Plasm.maximum(:age) |> Repo.one
Puppy |> Plasm.maximum("age") |> Repo.one
Specs
minimum(Ecto.Queryable, String.t) :: Ecto.Queryable
minimum(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a minimum query for a given field.
Puppy |> Plasm.minimum(:age) |> Repo.one
Puppy |> Plasm.minimum("age") |> Repo.one
Specs
on(Ecto.Queryable, atom, %Ecto.Date{day: term, month: term, year: term}) :: Ecto.Queryable
on(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records on a specified date for a specified field name.
Puppy |> Plasm.on(:inserted_at, ecto_date) |> Repo.all
Puppy |> Plasm.on(:inserted_at, "2014-04-17") |> Repo.all
Specs
on_or_earlier_than(Ecto.Queryable, atom, %Ecto.Date{day: term, month: term, year: term}) :: Ecto.Queryable
on_or_earlier_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records on or before a specified date for a specified field name.
Puppy |> Plasm.on_or_earlier_than(ecto_date) |> Repo.all
Puppy |> Plasm.on_or_earlier_than("2014-04-17") |> Repo.all
Specs
on_or_later_than(Ecto.Queryable, atom, %Ecto.Date{day: term, month: term, year: term}) :: Ecto.Queryable
on_or_later_than(Ecto.Queryable, atom, any) :: Ecto.Queryable
Builds a query that finds all records on or after a specified date for a specified field name.
Puppy |> Plasm.on_or_later_than(ecto_date) |> Repo.all
Puppy |> Plasm.on_or_later_than("2014-04-17") |> Repo.all
Specs
random(Ecto.Queryable) :: Ecto.Queryable
Builds a query that grabs a random record.
Optionally, provide an integer n
to fetch n
random records.
Puppy |> Plasm.random |> Repo.one
Puppy |> Plasm.random(20) |> Repo.all
Specs
total(Ecto.Queryable, String.t) :: Ecto.Queryable
total(Ecto.Queryable, atom) :: Ecto.Queryable
Builds a sum query for a given field.
Puppy |> Plasm.total(:age) |> Repo.one
Puppy |> Plasm.total("age") |> Repo.one
Specs
where_all(Ecto.Queryable, list) :: Ecto.Queryable
Builds a query that finds all records matching all specified field names and values.
Values can be lists or non-lists.
When the values are all non-lists, it simply delegates to Ecto.Query.where
.
When there is at least one list value, it builds the query itself, using in
for lists.
Puppy |> Plasm.where_all(name: "Fluffy", age: 3) |> Repo.all
Puppy |> Plasm.where_all(name: "Fluffy", age: [3,5,10]) |> Repo.all
Specs
where_none(Ecto.Queryable, list) :: Ecto.Queryable
Builds a query that finds all records matching none of the specified field names and values.
Values can be lists or non-lists.
Non-list expressions result in a !=
comparison.
List expressions result in a not in
comparison.
Puppy |> Plasm.where_none(name: "Fluffy", age: 3) |> Repo.all
Puppy |> Plasm.where_none(name: "Fluffy", age: [3,5,10]) |> Repo.all