Ecto.Repo.one
You're seeing just the callback
one
, go back to Ecto.Repo module for more information.
Specs
one(queryable :: Ecto.Queryable.t(), opts :: Keyword.t()) :: Ecto.Schema.t() | nil
Fetches a single result from the query.
Returns nil
if no result was found. Raises if more than one entry.
Options
:prefix
- The prefix to run the query on (such as the schema path in Postgres or the database in MySQL). This will be applied to allfrom
andjoin
s in the query that did not have a prefix previously given either via the:prefix
option onjoin
/from
or via@schema_prefix
in the schema. For more information see the "Query Prefix" section of theEcto.Query
documentation.
See the "Shared options" section at the module documentation for more options.
Examples
Repo.one(from p in Post, join: c in assoc(p, :comments), where: p.id == ^post_id)
query = from p in Post, join: c in assoc(p, :comments), where: p.id == ^post_id
Repo.one(query, prefix: "private")