plasm v0.4.0 Plasm
Summary
Functions
Builds an avg 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 matching any of the primary key values in the provided list or value
Builds a query that finds the first record after sorting by inserted_at
ascending
Builds a query that finds all records inserted after a specified %Ecto.DateTime{}
Builds a query that finds all records inserted on or after a specified %Ecto.DateTime{}
Builds a query that finds all records inserted before a specified %Ecto.DateTime{}
Builds a query that finds all records inserted on or before a specified %Ecto.DateTime{}
Builds a query that finds the last record after sorting by inserted_at
ascending
Builds a max query for a given field
Builds a min query for a given field
Builds a query that grabs a random record
Builds a sum query for a given field
Builds a query that finds all records updated after a specified %Ecto.DateTime{}
Builds a query that finds all records updated on or after a specified %Ecto.DateTime{}
Builds a query that finds all records updated before a specified %Ecto.DateTime{}
Builds a query that finds all records updated on or before a specified %Ecto.DateTime{}
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
avg(Ecto.Queryable, atom) :: Ecto.Queryable
avg(Ecto.Queryable, String.t) :: Ecto.Queryable
Builds an avg query for a given field.
Puppy |> Plasm.avg(:age) |> Repo.one
Puppy |> Plasm.avg("age") |> Repo.one
Specs
count(Ecto.Queryable) :: Ecto.Queryable
Builds a count query.
Puppy |> Plasm.count |> Repo.one
Specs
count_distinct(Ecto.Queryable, atom) :: Ecto.Queryable
count_distinct(Ecto.Queryable, String.t) :: 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, atom) :: Ecto.Queryable
distinct_by(Ecto.Queryable, String.t) :: 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
find(Ecto.Queryable, any) :: Ecto.Queryable
find(Ecto.Queryable, list) :: 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
first_inserted(Ecto.Queryable) :: Ecto.Queryable
Builds a query that finds the first record after sorting by inserted_at
ascending.
Optionally, provide an integer n
to find only the first n
records.
Puppy |> Plasm.first |> Repo.one
Puppy |> Plasm.first(20) |> Repo.all
Specs
inserted_after(Ecto.Queryable, any) :: Ecto.Queryable
inserted_after(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
inserted_after(Ecto.Queryable, any) :: Ecto.Queryable
inserted_after(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records inserted after a specified %Ecto.DateTime{}
.
Puppy |> Plasm.inserted_after(ecto_date_time) |> Repo.all
Puppy |> Plasm.inserted_after("2014-04-17T14:00:00Z") |> Repo.all
Builds a query that finds all records inserted on or after a specified %Ecto.DateTime{}
.
Puppy |> Plasm.inserted_after_incl(ecto_date_time) |> Repo.all
Puppy |> Plasm.inserted_after_incl("2014-04-17T14:00:00Z") |> Repo.all
Specs
inserted_before(Ecto.Queryable, any) :: Ecto.Queryable
inserted_before(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records inserted before a specified %Ecto.DateTime{}
.
Puppy |> Plasm.inserted_before(ecto_date_time) |> Repo.all
Puppy |> Plasm.inserted_before("2014-04-17T14:00:00Z") |> Repo.all
Specs
inserted_before_incl(Ecto.Queryable, any) :: Ecto.Queryable
inserted_before_incl(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records inserted on or before a specified %Ecto.DateTime{}
.
Puppy |> Plasm.inserted_before_incl(ecto_date_time) |> Repo.all
Puppy |> Plasm.inserted_before_incl("2014-04-17T14:00:00Z") |> Repo.all
Specs
last_inserted(Ecto.Queryable) :: Ecto.Queryable
Builds a query that finds the last record after sorting by inserted_at
ascending.
Optionally, provide an integer n
to find only the last n
records.
Puppy |> Plasm.last |> Repo.one
Puppy |> Plasm.last(20) |> Repo.all
Specs
max(Ecto.Queryable, atom) :: Ecto.Queryable
max(Ecto.Queryable, String.t) :: Ecto.Queryable
Builds a max query for a given field.
Puppy |> Plasm.max(:age) |> Repo.one
Puppy |> Plasm.max("age") |> Repo.one
Specs
min(Ecto.Queryable, atom) :: Ecto.Queryable
min(Ecto.Queryable, String.t) :: Ecto.Queryable
Builds a min query for a given field.
Puppy |> Plasm.min(:age) |> Repo.one
Puppy |> Plasm.min("age") |> Repo.one
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
sum(Ecto.Queryable, atom) :: Ecto.Queryable
sum(Ecto.Queryable, String.t) :: Ecto.Queryable
Builds a sum query for a given field.
Puppy |> Plasm.sum(:age) |> Repo.one
Puppy |> Plasm.sum("age") |> Repo.one
Specs
updated_after(Ecto.Queryable, any) :: Ecto.Queryable
updated_after(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records updated after a specified %Ecto.DateTime{}
.
Puppy |> Plasm.updated_after(ecto_date_time) |> Repo.all
Puppy |> Plasm.updated_after("2014-04-17T14:00:00Z") |> Repo.all
Specs
updated_after_incl(Ecto.Queryable, any) :: Ecto.Queryable
updated_after_incl(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records updated on or after a specified %Ecto.DateTime{}
.
Puppy |> Plasm.updated_after_incl(ecto_date_time) |> Repo.all
Puppy |> Plasm.updated_after_incl("2014-04-17T14:00:00Z") |> Repo.all
Specs
updated_before(Ecto.Queryable, any) :: Ecto.Queryable
updated_before(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records updated before a specified %Ecto.DateTime{}
.
Puppy |> Plasm.updated_before(ecto_date_time) |> Repo.all
Puppy |> Plasm.updated_before("2014-04-17T14:00:00Z") |> Repo.all
Specs
updated_before_incl(Ecto.Queryable, any) :: Ecto.Queryable
updated_before_incl(Ecto.Queryable, %Ecto.DateTime{day: term, hour: term, min: term, month: term, sec: term, usec: term, year: term}) :: Ecto.Queryable
Builds a query that finds all records updated on or before a specified %Ecto.DateTime{}
.
Puppy |> Plasm.updated_before_incl(ecto_date_time) |> Repo.all
Puppy |> Plasm.updated_before_incl("2014-04-17T14:00:00Z") |> Repo.all
Specs
where_all(Ecto.Queryable, list) :: Ecto.Queryable
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
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