// 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 card import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" ) const ( // Label holds the string label denoting the card type in the database. Label = "card" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldType holds the string denoting the type field in the database. FieldType = "type" // FieldNumberHash holds the string denoting the number_hash field in the database. FieldNumberHash = "number_hash" // FieldCvvHash holds the string denoting the cvv_hash field in the database. FieldCvvHash = "cvv_hash" // FieldExpiresAt holds the string denoting the expires_at field in the database. FieldExpiresAt = "expires_at" // FieldOwnerID holds the string denoting the owner_id field in the database. FieldOwnerID = "owner_id" // EdgeOwner holds the string denoting the owner edge name in mutations. EdgeOwner = "owner" // EdgePayments holds the string denoting the payments edge name in mutations. EdgePayments = "payments" // Table holds the table name of the card in the database. Table = "cards" // OwnerTable is the table that holds the owner relation/edge. OwnerTable = "cards" // OwnerInverseTable is the table name for the User entity. // It exists in this package in order to avoid circular dependency with the "user" package. OwnerInverseTable = "users" // OwnerColumn is the table column denoting the owner relation/edge. OwnerColumn = "owner_id" // PaymentsTable is the table that holds the payments relation/edge. PaymentsTable = "payments" // PaymentsInverseTable is the table name for the Payment entity. // It exists in this package in order to avoid circular dependency with the "payment" package. PaymentsInverseTable = "payments" // PaymentsColumn is the table column denoting the payments relation/edge. PaymentsColumn = "card_id" ) // Columns holds all SQL columns for card fields. var Columns = []string{ FieldID, FieldType, FieldNumberHash, FieldCvvHash, FieldExpiresAt, FieldOwnerID, } // 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 ( // DefaultType holds the default value on creation for the "type" field. DefaultType string // DefaultOwnerID holds the default value on creation for the "owner_id" field. DefaultOwnerID int ) // OrderOption defines the ordering options for the Card 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() } // ByType orders the results by the type field. func ByType(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldType, opts...).ToFunc() } // ByNumberHash orders the results by the number_hash field. func ByNumberHash(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldNumberHash, opts...).ToFunc() } // ByCvvHash orders the results by the cvv_hash field. func ByCvvHash(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCvvHash, opts...).ToFunc() } // ByExpiresAt orders the results by the expires_at field. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldExpiresAt, opts...).ToFunc() } // ByOwnerID orders the results by the owner_id field. func ByOwnerID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldOwnerID, opts...).ToFunc() } // ByOwnerField orders the results by owner field. func ByOwnerField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newOwnerStep(), sql.OrderByField(field, opts...)) } } // ByPaymentsCount orders the results by payments count. func ByPaymentsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborsCount(s, newPaymentsStep(), opts...) } } // ByPayments orders the results by payments terms. func ByPayments(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newPaymentsStep(), append([]sql.OrderTerm{term}, terms...)...) } } func newOwnerStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(OwnerInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn), ) } func newPaymentsStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(PaymentsInverseTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, PaymentsTable, PaymentsColumn), ) }