// Code generated by ent, DO NOT EDIT. package promocode import ( "time" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the promocode type in the database. Label = "promo_code" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldCode holds the string denoting the code field in the database. FieldCode = "code" // FieldBonusAmount holds the string denoting the bonus_amount field in the database. FieldBonusAmount = "bonus_amount" // FieldMaxUses holds the string denoting the max_uses field in the database. FieldMaxUses = "max_uses" // FieldUsedCount holds the string denoting the used_count field in the database. FieldUsedCount = "used_count" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // FieldExpiresAt holds the string denoting the expires_at field in the database. FieldExpiresAt = "expires_at" // FieldNotes holds the string denoting the notes field in the database. FieldNotes = "notes" // FieldCreatedAt holds the string denoting the created_at field in the database. FieldCreatedAt = "created_at" // FieldUpdatedAt holds the string denoting the updated_at field in the database. FieldUpdatedAt = "updated_at" // EdgeUsageRecords holds the string denoting the usage_records edge name in mutations. EdgeUsageRecords = "usage_records" // Table holds the table name of the promocode in the database. Table = "promo_codes" // UsageRecordsTable is the table that holds the usage_records relation/edge. UsageRecordsTable = "promo_code_usages" // UsageRecordsInverseTable is the table name for the PromoCodeUsage entity. // It exists in this package in order to avoid circular dependency with the "promocodeusage" package. UsageRecordsInverseTable = "promo_code_usages" // UsageRecordsColumn is the table column denoting the usage_records relation/edge. UsageRecordsColumn = "promo_code_id" ) // Columns holds all SQL columns for promocode fields. var Columns = []string{ FieldID, FieldCode, FieldBonusAmount, FieldMaxUses, FieldUsedCount, FieldStatus, FieldExpiresAt, FieldNotes, FieldCreatedAt, FieldUpdatedAt, } // ValidColumn reports if the column name is valid (part of the table columns). func ValidColumn(column string) bool { for i := range Columns { if column == Columns[i] { return true } } return false } var ( // CodeValidator is a validator for the "code" field. It is called by the builders before save. CodeValidator func(string) error // DefaultBonusAmount holds the default value on creation for the "bonus_amount" field. DefaultBonusAmount float64 // DefaultMaxUses holds the default value on creation for the "max_uses" field. DefaultMaxUses int // DefaultUsedCount holds the default value on creation for the "used_count" field. DefaultUsedCount int // DefaultStatus holds the default value on creation for the "status" field. DefaultStatus string // StatusValidator is a validator for the "status" field. It is called by the builders before save. StatusValidator func(string) error // DefaultCreatedAt holds the default value on creation for the "created_at" field. DefaultCreatedAt func() time.Time // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. DefaultUpdatedAt func() time.Time // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. UpdateDefaultUpdatedAt func() time.Time ) // OrderOption defines the ordering options for the PromoCode queries. type OrderOption func(*sql.Selector) // ByID orders the results by the id field. func ByID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldID, opts...).ToFunc() } // ByCode orders the results by the code field. func ByCode(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCode, opts...).ToFunc() } // ByBonusAmount orders the results by the bonus_amount field. func ByBonusAmount(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldBonusAmount, opts...).ToFunc() } // ByMaxUses orders the results by the max_uses field. func ByMaxUses(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldMaxUses, opts...).ToFunc() } // ByUsedCount orders the results by the used_count field. func ByUsedCount(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUsedCount, opts...).ToFunc() } // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } // ByExpiresAt orders the results by the expires_at field. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldExpiresAt, opts...).ToFunc() } // ByNotes orders the results by the notes field. func ByNotes(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldNotes, opts...).ToFunc() } // ByCreatedAt orders the results by the created_at field. func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCreatedAt, opts...).ToFunc() } // ByUpdatedAt orders the results by the updated_at field. func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc() } // ByUsageRecordsCount orders the results by usage_records count. func ByUsageRecordsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newUsageRecordsStep(), opts...) } } // ByUsageRecords orders the results by usage_records terms. func ByUsageRecords(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newUsageRecordsStep(), append([]sql.OrderTerm{term}, terms...)...) } } func newUsageRecordsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(UsageRecordsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, UsageRecordsTable, UsageRecordsColumn), ) }