/ ent / subscription / subscription.go
subscription.go
  1  // Code generated by ent, DO NOT EDIT.
  2  
  3  package subscription
  4  
  5  import (
  6  	"time"
  7  
  8  	"entgo.io/ent/dialect/sql"
  9  	"entgo.io/ent/dialect/sql/sqlgraph"
 10  	"github.com/google/uuid"
 11  )
 12  
 13  const (
 14  	// Label holds the string label denoting the subscription type in the database.
 15  	Label = "subscription"
 16  	// FieldID holds the string denoting the id field in the database.
 17  	FieldID = "id"
 18  	// FieldUserID holds the string denoting the user_id field in the database.
 19  	FieldUserID = "user_id"
 20  	// FieldFeedID holds the string denoting the feed_id field in the database.
 21  	FieldFeedID = "feed_id"
 22  	// FieldName holds the string denoting the name field in the database.
 23  	FieldName = "name"
 24  	// FieldGroup holds the string denoting the group field in the database.
 25  	FieldGroup = "group"
 26  	// FieldCreatedAt holds the string denoting the created_at field in the database.
 27  	FieldCreatedAt = "created_at"
 28  	// EdgeUser holds the string denoting the user edge name in mutations.
 29  	EdgeUser = "user"
 30  	// EdgeFeed holds the string denoting the feed edge name in mutations.
 31  	EdgeFeed = "feed"
 32  	// Table holds the table name of the subscription in the database.
 33  	Table = "subscriptions"
 34  	// UserTable is the table that holds the user relation/edge.
 35  	UserTable = "subscriptions"
 36  	// UserInverseTable is the table name for the User entity.
 37  	// It exists in this package in order to avoid circular dependency with the "user" package.
 38  	UserInverseTable = "users"
 39  	// UserColumn is the table column denoting the user relation/edge.
 40  	UserColumn = "user_id"
 41  	// FeedTable is the table that holds the feed relation/edge.
 42  	FeedTable = "subscriptions"
 43  	// FeedInverseTable is the table name for the Feed entity.
 44  	// It exists in this package in order to avoid circular dependency with the "feed" package.
 45  	FeedInverseTable = "feeds"
 46  	// FeedColumn is the table column denoting the feed relation/edge.
 47  	FeedColumn = "feed_id"
 48  )
 49  
 50  // Columns holds all SQL columns for subscription fields.
 51  var Columns = []string{
 52  	FieldID,
 53  	FieldUserID,
 54  	FieldFeedID,
 55  	FieldName,
 56  	FieldGroup,
 57  	FieldCreatedAt,
 58  }
 59  
 60  // ValidColumn reports if the column name is valid (part of the table columns).
 61  func ValidColumn(column string) bool {
 62  	for i := range Columns {
 63  		if column == Columns[i] {
 64  			return true
 65  		}
 66  	}
 67  	return false
 68  }
 69  
 70  var (
 71  	// NameValidator is a validator for the "name" field. It is called by the builders before save.
 72  	NameValidator func(string) error
 73  	// GroupValidator is a validator for the "group" field. It is called by the builders before save.
 74  	GroupValidator func(string) error
 75  	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
 76  	DefaultCreatedAt func() time.Time
 77  	// DefaultID holds the default value on creation for the "id" field.
 78  	DefaultID func() uuid.UUID
 79  )
 80  
 81  // OrderOption defines the ordering options for the Subscription queries.
 82  type OrderOption func(*sql.Selector)
 83  
 84  // ByID orders the results by the id field.
 85  func ByID(opts ...sql.OrderTermOption) OrderOption {
 86  	return sql.OrderByField(FieldID, opts...).ToFunc()
 87  }
 88  
 89  // ByUserID orders the results by the user_id field.
 90  func ByUserID(opts ...sql.OrderTermOption) OrderOption {
 91  	return sql.OrderByField(FieldUserID, opts...).ToFunc()
 92  }
 93  
 94  // ByFeedID orders the results by the feed_id field.
 95  func ByFeedID(opts ...sql.OrderTermOption) OrderOption {
 96  	return sql.OrderByField(FieldFeedID, opts...).ToFunc()
 97  }
 98  
 99  // ByName orders the results by the name field.
100  func ByName(opts ...sql.OrderTermOption) OrderOption {
101  	return sql.OrderByField(FieldName, opts...).ToFunc()
102  }
103  
104  // ByGroup orders the results by the group field.
105  func ByGroup(opts ...sql.OrderTermOption) OrderOption {
106  	return sql.OrderByField(FieldGroup, opts...).ToFunc()
107  }
108  
109  // ByCreatedAt orders the results by the created_at field.
110  func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
111  	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
112  }
113  
114  // ByUserField orders the results by user field.
115  func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
116  	return func(s *sql.Selector) {
117  		sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
118  	}
119  }
120  
121  // ByFeedField orders the results by feed field.
122  func ByFeedField(field string, opts ...sql.OrderTermOption) OrderOption {
123  	return func(s *sql.Selector) {
124  		sqlgraph.OrderByNeighborTerms(s, newFeedStep(), sql.OrderByField(field, opts...))
125  	}
126  }
127  func newUserStep() *sqlgraph.Step {
128  	return sqlgraph.NewStep(
129  		sqlgraph.From(Table, FieldID),
130  		sqlgraph.To(UserInverseTable, FieldID),
131  		sqlgraph.Edge(sqlgraph.M2O, false, UserTable, UserColumn),
132  	)
133  }
134  func newFeedStep() *sqlgraph.Step {
135  	return sqlgraph.NewStep(
136  		sqlgraph.From(Table, FieldID),
137  		sqlgraph.To(FeedInverseTable, FieldID),
138  		sqlgraph.Edge(sqlgraph.M2O, false, FeedTable, FeedColumn),
139  	)
140  }