Skip to content

Latest commit

 

History

History
34 lines (27 loc) · 477 Bytes

schema-config.md

File metadata and controls

34 lines (27 loc) · 477 Bytes
id title
schema-config
Config

自定义表名

可以像下面的例子一样,使用 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"),
	}
}