talira

An entity framework for Go

open sourceApache-2.0self-hostablefree

ent is an entity framework (ORM) for Go that models the database schema as a graph and defines it in Go code: each entity's schema declares its fields, edges, indexes and mixins, and ent generates a 100% statically typed, explicit API for CRUD, queries, aggregations and graph traversals with eager loading. Hooks, interceptors and a privacy layer add behaviour around operations, and migrations run automatically or as versioned migrations through Atlas. It supports MySQL, MariaDB, TiDB, PostgreSQL, CockroachDB, SQLite and Gremlin, integrates with GraphQL, and can be extended with Go templates. Inspired by Ent, an entity framework used inside Meta, it was created at Facebook and is now maintained by the Atlas team. Apache-2.0 licensed.

Problems it solves

  • a type-safe ORM for Go that generates code instead of using reflection
  • define my Go app's database schema in code and generate the data access layer
  • query related records and traverse relationships in Go without hand-written joins
  • run versioned database migrations for a Go project
  • add authorization rules at the data layer of a Go app
  • generate a GraphQL server from my Go database schema

Features

  • schema as Go code: fields, edges, indexes, mixins and annotations
  • statically typed, explicit API generated from the schema
  • CRUD, predicates, aggregations, paging and ordering
  • graph traversal and eager loading
  • hooks, interceptors and a privacy layer
  • transactions
  • automatic and versioned migrations (with Atlas)
  • MySQL, MariaDB, TiDB, PostgreSQL, CockroachDB, SQLite and Gremlin
  • GraphQL integration
  • extension through Go templates

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known

Alternatives

The same job

These do what ent does.

  1. sqlc Compile SQL to type-safe code
  2. Bun Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

Compare ent with the top 3