Ecto.Repo.exists-question-mark
You're seeing just the callback
exists-question-mark
, go back to Ecto.Repo module for more information.
Specs
exists?(queryable :: Ecto.Queryable.t(), opts :: Keyword.t()) :: boolean()
Checks if there exists an entry that matches the given query.
Returns a boolean.
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
# checks if any posts exist
Repo.exists?(Post)
# checks if any posts exist in the "private" schema path (in Postgres) or
# database (in MySQL)
Repo.exists?(Post, schema: "private")
# checks if any post with a like count greater than 10 exists
query = from p in Post, where: p.like_count > 10
Repo.exists?(query)