Hi everyone, I just found an awesome ORM in Go, that is ent (go-ent). This library provides a code generation feature. With this feature, we-developers can have code suggestions about fields of the table, and easy to write a query to filter records based on condition, unlike other ORMs in Go like gorm, we have to write the raw condition of SQL query
db.Where("name <> ?", "Jinzhou").Find(&users)
In this article, I will dive into the architecture of the ent framework, ...
Ent's main packages
- cmd: defines commands for the library.
- dialect: handles the dialect support for Mysql, PostgreSQL, SQLite, and Gremlin databases. The package also provides methods for the query builder.
- entql: provides (Unary, Binary, ... Expr) structs that implement
Stringer
interface, these structs generate the expression from their properties. - entc: provides an interface for interacting with entc (ent codegen) as a package rather than an executable
- privacy: provides a set of rules for user schema and deals with runtime evaluation.
- schema: contains structs that are used by developers when defining an ent schema.
Top comments (0)