Endon.scope

You're seeing just the function scope, go back to Endon module for more information.

Specs

Create a query with the given conditions (the same as where/2 accepts).

This will not actually run the query, so you will need to pass the result to where/2 or Ecto.Repo.all/2/Ecto.Repo.one/2.

For instance, this will just run one query to find a record with id 1 with name Bill.

Post.scope(id: 1) |> Post.scope(name: 'Bill') |> Post.first()

This is just a helpful function to make adding conditions easier to an existing Ecto.Schema

Link to this function

scope(query, conditions)

View Source

Specs

Take a query and add conditions (the same as where/2 accepts).

This will not actually run the query, so you will need to pass the result to where/2 or Ecto.Repo.all/2/Ecto.Repo.one/2.

For instance:

existing_query = from x in Post
Post.scope(existing_query, id: 1) |> Post.first()

This is just a helpful function to make adding conditions easier to an existing query.