ent-zh_cn
  • ent 中文文档
  • 入门指南
    • 快速入门
  • Schema
    • 介绍
    • 字段
    • 边
    • 索引
    • 配置
    • Mixin
  • 代码生成
    • 介绍
    • 增查改删 API
    • 图遍历
    • 数据聚合
    • 条件查询
    • 分页和排序
    • 事务
  • 迁移
    • 数据库迁移
    • 支持的方言
  • 杂项
    • sql.DB 集成
Powered by GitBook
On this page

Was this helpful?

  1. Schema

配置

可以像下面的例子一样,使用 Table 选项自定义表名。

package schema

import (
    "github.com/facebookincubator/ent"
    "github.com/facebookincubator/ent/schema/field"
)

type User struct {
    ent.Schema
}

func (User) Config() ent.Config {
    return ent.Config{
        Table: "Users",
    }
}

func (User) Fields() []ent.Field {
    return []ent.Field{
        field.Int("age"),
        field.String("name"),
    }
}
Previous索引NextMixin

Last updated 5 years ago

Was this helpful?