plasm v0.2.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 (atom)

Builds a distinct query for a given field (atom)

Builds a query that finds the record matching the provided primary key value

Builds a query that finds the first record after sorting by inserted_at ascending

Builds a query that finds the first n records after sorting by inserted_at ascending

Builds a query that finds all records inserted after a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records inserted on or after a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records inserted before a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records inserted on or before a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds the last record after sorting by inserted_at ascending

Builds a query that finds the last n records 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 query that grabs n random records

Builds a sum query for a given field

Builds a query that finds all records updated after a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records updated on or after a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records updated before a specified string that is castable to %Ecto.DateTime{}

Builds a query that finds all records updated on or before a specified string that is castable to %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

avg(query, field_name)

Builds an avg query for a given field.

Puppy |> Plasm.avg(:age) |> Repo.one
count(query)

Builds a count query.

Puppy |> Plasm.count |> Repo.one
count_distinct(query, field_name)

Builds a distinct count query for a given field (atom).

Puppy |> Plasm.count_distinct(:name) |> Repo.one
distinct_by(query, field_name)

Builds a distinct query for a given field (atom).

Puppy |> Plasm.distinct_by(:name) |> Repo.all
find(query, primary_key_values)

Builds a query that finds the record matching the provided primary key value.

Puppy |> Plasm.find(10) |> Repo.one
first(query)

Builds a query that finds the first record after sorting by inserted_at ascending.

Puppy |> Plasm.first |> Repo.one
first(query, n)

Builds a query that finds the first n records after sorting by inserted_at ascending.

Puppy |> Plasm.first(20) |> Repo.all
inserted_after(query, ecto_date_time)

Builds a query that finds all records inserted after a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.inserted_after("2014-04-17T14:00:00Z") |> Repo.all
inserted_after_incl(query, ecto_date_time)

Builds a query that finds all records inserted on or after a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.inserted_after_incl("2014-04-17T14:00:00Z") |> Repo.all
inserted_before(query, ecto_date_time)

Builds a query that finds all records inserted before a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.inserted_before("2014-04-17T14:00:00Z") |> Repo.all
inserted_before_incl(query, ecto_date_time)

Builds a query that finds all records inserted on or before a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.inserted_before_incl("2014-04-17T14:00:00Z") |> Repo.all
last(query)

Builds a query that finds the last record after sorting by inserted_at ascending.

Puppy |> Plasm.last |> Repo.one
last(query, n)

Builds a query that finds the last n records after sorting by inserted_at ascending.

Puppy |> Plasm.last(20) |> Repo.all
max(query, field_name)

Builds a max query for a given field.

Puppy |> Plasm.max(:age) |> Repo.one
min(query, field_name)

Builds a min query for a given field.

Puppy |> Plasm.min(:age) |> Repo.one
random(query)

Builds a query that grabs a random record.

Puppy |> Plasm.random |> Repo.one
random(query, n)

Builds a query that grabs n random records.

Puppy |> Plasm.random(20) |> Repo.all
sum(query, field_name)

Builds a sum query for a given field.

Puppy |> Plasm.sum(:age) |> Repo.one
updated_after(query, ecto_date_time)

Builds a query that finds all records updated after a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.updated_after("2014-04-17T14:00:00Z") |> Repo.all
updated_after_incl(query, ecto_date_time)

Builds a query that finds all records updated on or after a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.updated_after_incl("2014-04-17T14:00:00Z") |> Repo.all
updated_before(query, ecto_date_time)

Builds a query that finds all records updated before a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.updated_before("2014-04-17T14:00:00Z") |> Repo.all
updated_before_incl(query, ecto_date_time)

Builds a query that finds all records updated on or before a specified string that is castable to %Ecto.DateTime{}.

Puppy |> Plasm.updated_before_incl("2014-04-17T14:00:00Z") |> Repo.all
where_all(query, field_names_and_values)

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)

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