SchemaAssertions.Schema (Schema Assertions v2.1.0)

View Source

Ecto schema introspection

Summary

Functions

Returns true if the given module has a belongs_to relationship

Returns true if the given module is an Ecto schema

Returns :ok if the schema has a has_many relationship

Returns :ok if the schema has a has_one relationship

Returns true if the given module exists

Returns the database table name for the given module

Types

belongs_to_opts()

@type belongs_to_opts() :: [{:source, atom()}]

Functions

belongs_to?(module, assoc_name, assoc_module, opts \\ [])

@spec belongs_to?(module(), atom(), module(), opts :: belongs_to_opts()) ::
  :ok | {:error, String.t()}

Returns true if the given module has a belongs_to relationship

ecto_schema?(module)

@spec ecto_schema?(module()) :: boolean()

Returns true if the given module is an Ecto schema

has_many?(module, assoc_name, assoc_module_or_options)

@spec has_many?(module(), atom(), module() | Keyword.t()) ::
  :ok | {:error, atom(), String.t()}

Returns :ok if the schema has a has_many relationship

has_one?(module, assoc_name, assoc_module_or_options)

@spec has_one?(module(), atom(), module() | Keyword.t()) ::
  :ok | {:error, atom(), String.t()}

Returns :ok if the schema has a has_one relationship

module_exists?(module)

@spec module_exists?(module()) :: boolean()

Returns true if the given module exists

table_name(module)

@spec table_name(module()) :: binary()

Returns the database table name for the given module