// Copyright 2019-present Facebook Inc. All rights reserved. // This source code is licensed under the Apache 2.0 license found // in the LICENSE file in the root directory of this source tree. // Code generated by ent, DO NOT EDIT. package payment import ( "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the payment type in the database. Label = "payment" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldCardID holds the string denoting the card_id field in the database. FieldCardID = "card_id" // FieldAmount holds the string denoting the amount field in the database. FieldAmount = "amount" // FieldCurrency holds the string denoting the currency field in the database. FieldCurrency = "currency" // FieldTime holds the string denoting the time field in the database. FieldTime = "time" // FieldDescription holds the string denoting the description field in the database. FieldDescription = "description" // FieldStatus holds the string denoting the status field in the database. FieldStatus = "status" // EdgeCard holds the string denoting the card edge name in mutations. EdgeCard = "card" // Table holds the table name of the payment in the database. Table = "payments" // CardTable is the table that holds the card relation/edge. CardTable = "payments" // CardInverseTable is the table name for the Card entity. // It exists in this package in order to avoid circular dependency with the "card" package. CardInverseTable = "cards" // CardColumn is the table column denoting the card relation/edge. CardColumn = "card_id" ) // Columns holds all SQL columns for payment fields. var Columns = []string{ FieldID, FieldCardID, FieldAmount, FieldCurrency, FieldTime, FieldDescription, FieldStatus, } // 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 ( // AmountValidator is a validator for the "amount" field. It is called by the builders before save. AmountValidator func(float64) error ) // Currency defines the type for the "currency" enum field. type Currency string // Currency values. const ( CurrencyUSD Currency = "USD" CurrencyEUR Currency = "EUR" CurrencyVND Currency = "VND" CurrencyILS Currency = "ILS" ) func (c Currency) String() string { return string(c) } // CurrencyValidator is a validator for the "currency" field enum values. It is called by the builders before save. func CurrencyValidator(c Currency) error { switch c { case CurrencyUSD, CurrencyEUR, CurrencyVND, CurrencyILS: return nil default: return fmt.Errorf("payment: invalid enum value for currency field: %q", c) } } // Status defines the type for the "status" enum field. type Status string // Status values. const ( StatusPending Status = "pending" StatusCompleted Status = "completed" StatusFailed Status = "failed" ) func (s Status) String() string { return string(s) } // StatusValidator is a validator for the "status" field enum values. It is called by the builders before save. func StatusValidator(s Status) error { switch s { case StatusPending, StatusCompleted, StatusFailed: return nil default: return fmt.Errorf("payment: invalid enum value for status field: %q", s) } } // OrderOption defines the ordering options for the Payment 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() } // ByCardID orders the results by the card_id field. func ByCardID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCardID, opts...).ToFunc() } // ByAmount orders the results by the amount field. func ByAmount(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldAmount, opts...).ToFunc() } // ByCurrency orders the results by the currency field. func ByCurrency(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCurrency, opts...).ToFunc() } // ByTime orders the results by the time field. func ByTime(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldTime, opts...).ToFunc() } // ByDescription orders the results by the description field. func ByDescription(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDescription, opts...).ToFunc() } // ByStatus orders the results by the status field. func ByStatus(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldStatus, opts...).ToFunc() } // ByCardField orders the results by card field. func ByCardField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newCardStep(), sql.OrderByField(field, opts...)) } } func newCardStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(CardInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, CardTable, CardColumn), ) }