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.1.7
v1.1.6
v1.1.5
v1.1.4
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.7
v1.0.6
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
v1.0.0
v0.16.0
v0.15.0
v0.14.3
v0.14.2
v0.14.1
v0.14.0
v0.13.1
v0.13.0
v0.12.1
v0.12.0
v0.12.0-rc
v0.11.3
v0.11.2
v0.11.1
v0.11.0
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.0
v0.8.1
v0.8.0
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.1
v0.5.0
v0.4.0
v0.3.0
v0.2.8
v0.2.7
v0.2.6
v0.2.5
GUIDES
Modules
Mix
Tasks
API Reference
Modules
Mix Tasks
Changelog for v3.x
v3.11.1 (2023-12-07)
v3.11.0 (2023-11-14)
v3.10.3 (2023-07-07)
v3.10.2 (2023-06-07)
v3.10.1 (2023-04-12)
v3.10.0 (2023-04-10)
v3.9.6 (2023-07-07)
v3.9.5 (2023-03-22)
v3.9.4 (2022-12-21)
v3.9.3 (2022-12-20)
v3.9.2 (2022-11-18)
v3.9.1 (2022-10-06)
v3.9.0 (2022-09-27)
v3.8.4 (2022-06-04)
v3.8.3 (2022-05-11)
v3.8.2 (2022-05-05)
v3.8.1 (2022-04-27)
v3.8.0 (2022-04-26)
v3.7.2 (2022-03-13)
v3.7.1 (2021-08-27)
v3.7.0 (2021-08-19)
v3.6.2 (2021-05-28)
v3.6.1 (2021-04-12)
v3.6.0 (2021-04-03)
v3.5.8 (2021-02-21)
v3.5.7 (2021-02-07)
v3.5.6 (2021-01-20)
v3.5.5 (2020-11-12)
v3.5.4 (2020-10-28)
v3.5.3 (2020-10-21)
v3.5.2 (2020-10-12)
v3.5.1 (2020-10-08)
v3.5.0 (2020-10-03)
v3.4.6 (2020-08-07)
v3.4.5 (2020-06-14)
v3.4.4 (2020-05-11)
v3.4.3 (2020-04-27)
v3.4.2 (2020-04-10)
v3.4.1 (2020-04-08)
v3.4.0 (2020-03-24)
v3.3.4 (2020-02-27)
v3.3.3 (2020-02-14)
v3.3.2 (2020-01-28)
v3.3.1 (2019-12-27)
v3.3.0 (2019-12-11)
v3.2.5 (2019-11-03)
v3.2.4 (2019-11-02)
v3.2.3 (2019-10-17)
v3.2.2 (2019-10-01)
v3.2.1 (2019-09-17)
v3.2.0 (2019-09-07)
v3.1.7 (2019-06-27)
v3.1.6 (2019-06-19)
v3.1.5 (2019-06-06)
v3.1.4 (2019-05-07)
v3.1.3 (2019-04-30)
v3.1.2 (2019-04-24)
v3.1.1 (2019-04-04)
v3.1.0 (2019-04-02)
v3.0.7 (2019-02-06)
v3.0.6 (2018-12-31)
v3.0.5 (2018-12-08)
v3.0.4 (2018-11-29)
v3.0.3 (2018-11-20)
v3.0.2 (2018-11-17)
v3.0.1 (2018-11-03)
v3.0.0 (2018-10-29)
Previous versions
Introduction
Getting Started
Adding Ecto to an application
Setting up the database
Creating the schema
Inserting data
Validating changes
Our first queries
Updating records
Deleting records
Embedded Schemas
User Profile Example
Testing with Ecto
Cheatsheets
Basic CRUD
Fetching records
Querying records
Inserting records
Updating records
Deleting records
Associations
Has many / belongs to
Has one / belongs to
Many to many
Querying associated records
Inserting associated records
Updating associated records
How-To's
Aggregates and subqueries
Aggregates
Subqueries
Composable transactions with Multi
Composing with data structures
Dependent values
Constraints and Upserts
put_assoc vs cast_assoc
Constraints and race conditions
Checking for constraint errors
Upserts
Upserts and insert_all
Data mapping and validation
Schemas are mappers
Schemaless changesets
Dynamic queries
Focusing on data structures
Dynamic fragments
Building dynamic queries
Dynamic and joins
Multi tenancy with query prefixes
Connection prefixes
Schema prefixes
Per-query and per-struct prefixes
Per from/join prefixes
Migration prefixes
Summing up
Multi tenancy with foreign keys
Adding org_id to read operations
Setting org_id by default
Working with multi tenant associations
Summary
Self-referencing many to many
People relationships
Summary
Polymorphic associations with many to many
Todo lists v65131
Polymorphic todo items
Polymorphism with has_many :through
Polymorphism with many_to_many
Summary
Replicas and dynamic repositories
Primary and Replicas
Testing replicas
Dynamic repositories
Schemaless queries
insert_all, update_all and delete_all
Test factories
Ecto
Sections
Repositories
Schema
Changesets
Query
Other topics
Summary
Functions
assoc/3
assoc_loaded?/1
build_assoc/3
embedded_dump/2
embedded_load/3
get_meta/2
primary_key/1
primary_key!/1
put_meta/2
reset_fields/2
Ecto.Changeset
Sections
External vs internal data
Validations and constraints
Empty values
Associations, embeds, and on replace
Schemaless changesets
The Ecto.Changeset struct
Summary
Types
action/0
constraint/0
data/0
empty_value/0
error/0
t/0
t/1
traverse_result/0
types/0
Functions
add_error/4
apply_action/2
apply_action!/2
apply_changes/1
assoc_constraint/3
cast/4
cast_assoc/3
cast_embed/3
change/2
changed?/3
check_constraint/3
constraints/1
delete_change/2
empty_values/0
exclusion_constraint/3
fetch_change/2
fetch_change!/2
fetch_field/2
fetch_field!/2
field_missing?/2
force_change/3
foreign_key_constraint/3
get_assoc/3
get_change/3
get_embed/3
get_field/3
merge/2
no_assoc_constraint/3
optimistic_lock/3
prepare_changes/2
put_assoc/4
put_change/3
put_embed/4
traverse_errors/2
traverse_validations/2
unique_constraint/3
unsafe_validate_unique/4
update_change/3
validate_acceptance/3
validate_change/3
validate_change/4
validate_confirmation/3
validate_exclusion/4
validate_format/4
validate_inclusion/4
validate_length/3
validate_number/3
validate_required/3
validate_subset/4
validations/1
Ecto.Multi
Sections
Changesets
Run
Example
Summary
Types
changes/0
failure/0
fun/1
merge/0
name/0
run/0
t/0
Functions
all/4
append/2
delete/4
delete_all/4
error/3
exists?/4
insert/4
insert_all/5
insert_or_update/4
inspect/2
merge/2
merge/4
new/0
one/4
prepend/2
put/3
run/3
run/5
to_list/1
update/4
update_all/5
Ecto.Query
Sections
Query expressions
Interpolation and casting
nil comparison
Composition
Fragments
Macro API
Query prefix
Summary
Types
dynamic_expr/0
t/0
Functions
%Ecto.Query{}
distinct/3
dynamic/2
except/2
except_all/2
exclude/2
first/2
from/2
group_by/3
has_named_binding?/2
having/3
intersect/2
intersect_all/2
join/5
last/2
limit/3
lock/3
offset/3
or_having/3
or_where/3
order_by/3
preload/3
prepend_order_by/3
put_query_prefix/2
recursive_ctes/2
reverse_order/1
select/3
select_merge/3
subquery/2
union/2
union_all/2
update/3
where/3
windows/3
with_cte/3
with_named_binding/3
with_ties/3
Ecto.Repo
Sections
URLs
Shared options
Adapter-Specific Errors
Telemetry events
Read-only repositories
Summary
Types
t/0
Query API
aggregate/3
aggregate/4
all/2
delete_all/2
exists?/2
get/3
get!/3
get_by/3
get_by!/3
one/2
one!/2
stream/2
update_all/3
Schema API
delete/2
delete!/2
insert/2
insert!/2
insert_all/3
insert_or_update/2
insert_or_update!/2
load/2
preload/3
reload/2
reload!/2
update/2
update!/2
Transaction API
checked_out?/0
checkout/2
in_transaction?/0
rollback/1
transaction/2
Runtime API
__adapter__/0
config/0
get_dynamic_repo/0
put_dynamic_repo/1
start_link/1
stop/1
User callbacks
default_options/1
init/2
prepare_query/3
Functions
all_running/0
Ecto.Schema
Sections
Example
Redacting fields
Schema attributes
Primary keys
Types and casting
Reflection
Working with typespecs
Summary
Types
belongs_to/1
embedded_schema/0
embeds_many/1
embeds_one/1
has_many/1
has_one/1
many_to_many/1
prefix/0
schema/0
source/0
t/0
Functions
belongs_to/3
embedded_schema/1
embeds_many/3
embeds_many/4
embeds_one/3
embeds_one/4
field/3
has_many/3
has_one/3
many_to_many/3
schema/2
timestamps/1
Ecto.Schema.Metadata
Sections
State
Source
Prefix
Context
Schema
Summary
Types
context/0
state/0
t/0
t/1
Mix.Ecto
Summary
Functions
ensure_implements/3
ensure_repo/2
no_umbrella!/1
open?/2
parse_repo/1
Types
Ecto.Enum
Sections
Embeds
Summary
Functions
dump_values/2
mappings/2
values/2
Ecto.ParameterizedType
Sections
Examples
Summary
Types
opts/0
params/0
Callbacks
autogenerate/1
cast/2
dump/3
embed_as/2
equal?/3
format/1
init/1
load/3
type/1
Functions
init/2
Ecto.Type
Sections
Example
Custom types and primary keys
Summary
Types
base/0
composite/0
custom/0
primitive/0
t/0
Callbacks
autogenerate/0
cast/1
dump/1
embed_as/1
equal?/2
load/1
type/0
Functions
base?/1
cast/2
composite?/1
dump/3
embed_as/2
embedded_dump/3
embedded_load/3
equal?/3
format/1
include?/3
load/3
match?/2
primitive?/1
type/1
Ecto.UUID
Summary
Types
raw/0
t/0
Functions
bingenerate/0
cast/1
cast!/1
dump/1
dump!/1
embed_as/1
equal?/2
generate/0
load/1
load!/1
Query APIs
Ecto.Query.API
Sections
Intervals
Window API
About the arithmetic operators
Summary
Functions
*/2
+/2
-/2
//2
!=/2
</2
<=/2
==/2
>/2
>=/2
ago/2
all/1
and/2
any/1
as/1
avg/1
coalesce/2
count/0
count/1
count/2
date_add/3
datetime_add/3
exists/1
field/2
filter/2
fragment/1
from_now/2
ilike/2
in/2
is_nil/1
json_extract_path/2
like/2
literal/1
map/2
max/1
merge/2
min/1
not/1
or/2
parent_as/1
selected_as/1
selected_as/2
splice/1
struct/2
sum/1
type/2
values/2
Ecto.Query.WindowAPI
Summary
Functions
avg/1
count/0
count/1
cume_dist/0
dense_rank/0
filter/2
first_value/1
lag/3
last_value/1
lead/3
max/1
min/1
nth_value/2
ntile/1
over/2
percent_rank/0
rank/0
row_number/0
sum/1
Ecto.Queryable
Summary
Types
t/0
Functions
to_query/1
Ecto.SubQuery
Summary
Types
t/0
Adapter specification
Ecto.Adapter
Summary
Types
adapter_meta/0
t/0
Callbacks
__before_compile__/1
checked_out?/1
checkout/3
dumpers/2
ensure_all_started/2
init/1
loaders/2
Functions
lookup_meta/1
Ecto.Adapter.Queryable
Summary
Types
adapter_meta/0
cached/0
options/0
prepared/0
query_cache/0
query_meta/0
selected/0
Callbacks
execute/5
prepare/2
stream/5
Functions
plan_query/3
prepare_query/3
Ecto.Adapter.Schema
Summary
Types
adapter_meta/0
constraints/0
fields/0
filters/0
on_conflict/0
options/0
placeholders/0
returning/0
schema_meta/0
Callbacks
autogenerate/1
delete/5
insert/6
insert_all/8
update/6
Ecto.Adapter.Storage
Summary
Callbacks
storage_down/1
storage_status/1
storage_up/1
Ecto.Adapter.Transaction
Summary
Types
adapter_meta/0
Callbacks
in_transaction?/1
rollback/2
transaction/3
Relation structs
Ecto.Association.BelongsTo
Ecto.Association.Has
Ecto.Association.HasThrough
Ecto.Association.ManyToMany
Summary
Functions
assoc_query/2
Ecto.Association.NotLoaded
Summary
Types
t/0
Ecto.Embedded
Summary
Functions
preload_info/1
Exceptions
Ecto.CastError
Ecto.ChangeError
Ecto.ConstraintError
Ecto.InvalidChangesetError
Summary
Functions
message/1
Ecto.InvalidURLError
Ecto.MigrationError
Ecto.MultiplePrimaryKeyError
Ecto.MultipleResultsError
Ecto.NoPrimaryKeyFieldError
Ecto.NoPrimaryKeyValueError
Ecto.NoResultsError
Ecto.Query.CastError
Ecto.Query.CompileError
Ecto.QueryError
Ecto.StaleEntryError
Ecto.SubQueryError
mix ecto
mix ecto.create
Sections
Examples
Command line options
mix ecto.drop
Sections
Examples
Command line options
mix ecto.gen.repo
Sections
Examples
Command line options
Settings
View Source
Ecto.QueryError
exception
(Ecto v3.11.1)
Raised at runtime when the query is invalid.
×