github.com/ngocphuongnb/tetua@v0.0.7-alpha/packages/entrepository/ent/schema/setting.go (about)

     1  package schema
     2  
     3  import (
     4  	"entgo.io/ent"
     5  	"entgo.io/ent/dialect/entsql"
     6  	"entgo.io/ent/schema"
     7  	"entgo.io/ent/schema/field"
     8  	"entgo.io/ent/schema/index"
     9  )
    10  
    11  // Setting holds the schema definition for the Setting entity.
    12  type Setting struct {
    13  	ent.Schema
    14  }
    15  
    16  // Fields of the Setting.
    17  func (Setting) Fields() []ent.Field {
    18  	return []ent.Field{
    19  		field.String("name"),
    20  		field.Text("value").Optional(),
    21  		field.String("type").Optional().Default("input"),
    22  	}
    23  }
    24  
    25  func (Setting) Indexes() []ent.Index {
    26  	return []ent.Index{
    27  		index.Fields("name").Unique(),
    28  	}
    29  }
    30  
    31  func (Setting) Annotations() []schema.Annotation {
    32  	return []schema.Annotation{
    33  		entsql.Annotation{
    34  			Charset:   "utf8mb4",
    35  			Collation: "utf8mb4_unicode_ci",
    36  		},
    37  	}
    38  }
    39  
    40  // Edges of the Setting.
    41  func (Setting) Mixin() []ent.Mixin {
    42  	return []ent.Mixin{
    43  		TimeStamp{},
    44  	}
    45  }