// ==========================================================================
// This is auto-generated by gf cli tool. You may not really want to edit it.
// ==========================================================================

package model_fields

import (
	"database/sql"
	"github.com/gogf/gf/database/gdb"
)

// Entity is the golang structure for table model_fields.
type Entity struct {
	FieldId      uint64 `orm:"field_id,primary" json:"field_id"`      // 模型字段ID
	ModelId      uint   `orm:"model_id"         json:"model_id"`      // 模型ID
	FieldName    string `orm:"field_name"       json:"field_name"`    // 字段名称
	FieldTitle   string `orm:"field_title"      json:"field_title"`   // 字段标题
	FieldType    string `orm:"field_type"       json:"field_type"`    // 字段类型
	FieldLength  string `orm:"field_length"     json:"field_length"`  // 字段长度
	FieldDefault string `orm:"field_default"    json:"field_default"` // 字段默认值
	FieldData    string `orm:"field_data"       json:"field_data"`    // 字段数据
	FieldDesc    string `orm:"field_desc"       json:"field_desc"`    // 字段描述
	FieldRules   string `orm:"field_rules"      json:"field_rules"`   // 字段规则
	FieldSort    int64  `orm:"field_sort"       json:"field_sort"`    // 字段排序
	FieldWidth   string `orm:"field_width"       json:"field_width"`  // 字段列表显示宽度
	FieldAlign   string `orm:"field_align"       json:"field_align"`  // 字段列表对齐
	CreateBy     uint64 `orm:"create_by"        json:"create_by"`     // 创建人
	UpdateBy     uint64 `orm:"update_by"        json:"update_by"`     // 修改人
	CreateTime   uint64 `orm:"create_time"      json:"create_time"`   // 创建时间
	UpdateTime   uint64 `orm:"update_time"      json:"update_time"`   // 修改时间
}

// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
// the data and where attributes for empty values.
func (r *Entity) OmitEmpty() *arModel {
	return Model.Data(r).OmitEmpty()
}

// Inserts does "INSERT...INTO..." statement for inserting current object into table.
func (r *Entity) Insert() (result sql.Result, err error) {
	return Model.Data(r).Insert()
}

// InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
func (r *Entity) InsertIgnore() (result sql.Result, err error) {
	return Model.Data(r).InsertIgnore()
}

// Replace does "REPLACE...INTO..." statement for inserting current object into table.
// If there's already another same record in the table (it checks using primary key or unique index),
// it deletes it and insert this one.
func (r *Entity) Replace() (result sql.Result, err error) {
	return Model.Data(r).Replace()
}

// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Save() (result sql.Result, err error) {
	return Model.Data(r).Save()
}

// Update does "UPDATE...WHERE..." statement for updating current object from table.
// It updates the record if there's already another same record in the table
// (it checks using primary key or unique index).
func (r *Entity) Update() (result sql.Result, err error) {
	return Model.Data(r).Where(gdb.GetWhereConditionOfStruct(r)).Update()
}

// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
func (r *Entity) Delete() (result sql.Result, err error) {
	return Model.Where(gdb.GetWhereConditionOfStruct(r)).Delete()
}
