This page documents the primary Ecto-facing APIs and metadata used when compiling Haxe to idiomatic Ecto modules.
ecto.Schemaecto.Changesetecto.Repositoryecto.Queryandecto.TypedQueryecto.Migrationandecto.Migratorecto.DatabaseAdapterecto.test.Sandbox
Core schema tags:
@:schema("table_name")@:field@:primary_key@:timestamps@:virtual- associations such as
@:has_many
@:native("TodoApp.User")
@:schema("users")
@:timestamps
class User {
@:field @:primary_key public var id:Int;
@:field public var email:String;
@:virtual @:field public var password:String;
}Core changeset tags:
@:changeset(...)@:validate_required([...])@:validate_format(...)@:validate_length(...)@:validate_number(...)
These map to the standard Ecto validation pipeline and should be used instead of ad-hoc runtime string patching.
@:repo({...}) configures a repository module with typed adapter options.
@:native("TodoApp.Repo")
@:repo({adapter: Postgres, json: Jason, extensions: [], poolSize: 10})
extern class Repo {}ecto.Repository and typed query externs provide strongly-typed query entrypoints while still emitting standard Ecto usage.
Recommended user-facing patterns:
- Prefer typed query externs (
ecto.TypedQuery) and typed lambdas/macros - Keep table/schema references typed wherever possible
- Use
ROUTER_DSL.md-style typed refs philosophy analogously for query callsites: avoid stringly-typed schema identifiers
@:query currently appears as a reserved/forward-looking marker in examples; do not treat it as a stable codegen contract unless explicitly documented for your version.
@:migration marks migration classes for migration-specific processing.
- In
.exsmigration mode (-D ecto_migrations_exs), only the documented supported DSL subset is guaranteed. - For unsupported advanced migration shapes, use hand-written Elixir migrations.
ecto.test.Sandboxprovides typed test transaction/sandbox controls.- Pair sandbox setup with ExUnit metadata (
@:exunit,@:setup,@:teardown) for deterministic DB tests.
- Missing FK field expectations in associations (
@:belongs_to,@:has_many) when association validation is enabled - Overreliance on dynamic/untyped query snippets when typed query APIs exist
- Assuming all migration DSL shapes are rewritten in
.exsmode - Using generated runtime outputs as source-of-truth instead of changing
std/_std/*.hxor compiler pipeline sources
docs/04-api-reference/ANNOTATIONS.mddocs/04-api-reference/STDLIB_SUPPORT_MATRIX.mddocs/07-patterns/ECTO_INTEGRATION_PATTERNS.md