plasm v2.0.2 Plasm
Link to this section 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.
Link to this section Functions
at(query, field_name, date_time)
Specs
at(Ecto.Queryable.t(), atom(), %DateTime{ calendar: term(), day: term(), hour: term(), microsecond: term(), minute: term(), month: term(), second: term(), std_offset: term(), time_zone: term(), utc_offset: term(), year: term(), zone_abbr: term() }) :: Ecto.Queryable.t()
at(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
Builds a query that finds all records at a specified date and time for a specified field name.
Puppy |> Plasm.at(:updated_at, date_time) |> Repo.all
Puppy |> Plasm.at(:updated_at, "2014-04-17T14:00:00Z") |> Repo.all
at_or_earlier_than(query, field_name, date_time)
Specs
at_or_earlier_than(Ecto.Queryable.t(), atom(), %DateTime{ calendar: term(), day: term(), hour: term(), microsecond: term(), minute: term(), month: term(), second: term(), std_offset: term(), time_zone: term(), utc_offset: term(), year: term(), zone_abbr: term() }) :: Ecto.Queryable.t()
at_or_earlier_than(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
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, date_time) |> Repo.all
Puppy |> Plasm.at_or_earlier_than(:updated_at, "2014-04-17") |> Repo.all
at_or_later_than(query, field_name, date_time)
Specs
at_or_later_than(Ecto.Queryable.t(), atom(), %DateTime{ calendar: term(), day: term(), hour: term(), microsecond: term(), minute: term(), month: term(), second: term(), std_offset: term(), time_zone: term(), utc_offset: term(), year: term(), zone_abbr: term() }) :: Ecto.Queryable.t()
at_or_later_than(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
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, date_time) |> Repo.all
Puppy |> Plasm.at_or_later_than(:updated_at, "2014-04-17") |> Repo.all
average(query, field_name)
Specs
average(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
average(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds an average query for a given field.
Puppy |> Plasm.average(:age) |> Repo.one
Puppy |> Plasm.average("age") |> Repo.one
count(query)
Specs
count(Ecto.Queryable.t()) :: Ecto.Queryable.t()
Builds a count query.
Puppy |> Plasm.count |> Repo.one
count_distinct(query, field_name)
Specs
count_distinct(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
count_distinct(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds a distinct count query for a given field.
Puppy |> Plasm.count_distinct(:name) |> Repo.one
Puppy |> Plasm.count_distinct("age") |> Repo.one
distinct_by(query, field_name)
Specs
distinct_by(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
distinct_by(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds a distinct query for a given field.
Puppy |> Plasm.distinct_by(:age) |> Repo.all
Puppy |> Plasm.distinct_by("name") |> Repo.all
earlier_than(query, field_name, date)
Specs
earlier_than(Ecto.Queryable.t(), atom(), %Date{ calendar: term(), day: term(), month: term(), year: term() }) :: Ecto.Queryable.t()
earlier_than(Ecto.Queryable.t(), atom(), %DateTime{ calendar: term(), day: term(), hour: term(), microsecond: term(), minute: term(), month: term(), second: term(), std_offset: term(), time_zone: term(), utc_offset: term(), year: term(), zone_abbr: term() }) :: Ecto.Queryable.t()
earlier_than(Ecto.Queryable.t(), atom(), String.t() | number()) :: Ecto.Queryable.t()
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, date_or_date_time) |> Repo.all
Puppy |> Plasm.earlier_than(:updated_at, "2014-04-17") |> Repo.all
earliest(query, field_name)
Specs
earliest(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
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
earliest(query, field_name, n)
Specs
earliest(Ecto.Queryable.t(), atom(), integer()) :: Ecto.Queryable.t()
find(query, primary_key_values)
Specs
find(Ecto.Queryable.t(), list()) :: Ecto.Queryable.t()
find(Ecto.Queryable.t(), any()) :: Ecto.Queryable.t()
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
later_than(query, field_name, date)
Specs
later_than(Ecto.Queryable.t(), atom(), %Date{ calendar: term(), day: term(), month: term(), year: term() }) :: Ecto.Queryable.t()
later_than(Ecto.Queryable.t(), atom(), %DateTime{ calendar: term(), day: term(), hour: term(), microsecond: term(), minute: term(), month: term(), second: term(), std_offset: term(), time_zone: term(), utc_offset: term(), year: term(), zone_abbr: term() }) :: Ecto.Queryable.t()
later_than(Ecto.Queryable.t(), atom(), String.t() | number()) :: Ecto.Queryable.t()
Builds a query that finds all records after a specified field name and date or date and time.
Puppy |> Plasm.later_than(date) |> Repo.all
Puppy |> Plasm.later_than("2014-04-17") |> Repo.all
latest(query, field_name)
Specs
latest(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
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
latest(query, field_name, n)
Specs
latest(Ecto.Queryable.t(), atom(), integer()) :: Ecto.Queryable.t()
maximum(query, field_name)
Specs
maximum(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
maximum(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds a maximum query for a given field.
Puppy |> Plasm.maximum(:age) |> Repo.one
Puppy |> Plasm.maximum("age") |> Repo.one
minimum(query, field_name)
Specs
minimum(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
minimum(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds a minimum query for a given field.
Puppy |> Plasm.minimum(:age) |> Repo.one
Puppy |> Plasm.minimum("age") |> Repo.one
on(query, field_name, date)
Specs
on(Ecto.Queryable.t(), atom(), %Date{ calendar: term(), day: term(), month: term(), year: term() }) :: Ecto.Queryable.t()
on(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
Builds a query that finds all records on a specified date for a specified field name.
Puppy |> Plasm.on(:inserted_at, date) |> Repo.all
Puppy |> Plasm.on(:inserted_at, "2014-04-17") |> Repo.all
on_or_earlier_than(query, field_name, date)
Specs
on_or_earlier_than(Ecto.Queryable.t(), atom(), %Date{ calendar: term(), day: term(), month: term(), year: term() }) :: Ecto.Queryable.t()
on_or_earlier_than(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
Builds a query that finds all records on or before a specified date for a specified field name.
Puppy |> Plasm.on_or_earlier_than(date) |> Repo.all
Puppy |> Plasm.on_or_earlier_than("2014-04-17") |> Repo.all
on_or_later_than(query, field_name, date)
Specs
on_or_later_than(Ecto.Queryable.t(), atom(), %Date{ calendar: term(), day: term(), month: term(), year: term() }) :: Ecto.Queryable.t()
on_or_later_than(Ecto.Queryable.t(), atom(), any()) :: Ecto.Queryable.t()
Builds a query that finds all records on or after a specified date for a specified field name.
Puppy |> Plasm.on_or_later_than(date) |> Repo.all
Puppy |> Plasm.on_or_later_than("2014-04-17") |> Repo.all
random(query)
Specs
random(Ecto.Queryable.t()) :: Ecto.Queryable.t()
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
random(query, n)
Specs
random(Ecto.Queryable.t(), integer()) :: Ecto.Queryable.t()
total(query, field_name)
Specs
total(Ecto.Queryable.t(), String.t()) :: Ecto.Queryable.t()
total(Ecto.Queryable.t(), atom()) :: Ecto.Queryable.t()
Builds a sum query for a given field.
Puppy |> Plasm.total(:age) |> Repo.one
Puppy |> Plasm.total("age") |> Repo.one
where_all(query, field_names_and_values)
Specs
where_all(Ecto.Queryable.t(), list()) :: Ecto.Queryable.t()
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
where_none(query, field_names_and_values)
Specs
where_none(Ecto.Queryable.t(), list()) :: Ecto.Queryable.t()
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