online-order/ent/product/product.go

233 lines
8.9 KiB
Go
Raw Normal View History

2023-10-27 09:51:58 +00:00
// Code generated by ent, DO NOT EDIT.
package product
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the product type in the database.
Label = "product"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
2023-10-28 23:12:07 +00:00
// FieldSummary holds the string denoting the summary field in the database.
FieldSummary = "summary"
2023-10-27 09:51:58 +00:00
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldPrice holds the string denoting the price field in the database.
FieldPrice = "price"
// FieldOriginalPrice holds the string denoting the original_price field in the database.
FieldOriginalPrice = "original_price"
// FieldQuantity holds the string denoting the quantity field in the database.
FieldQuantity = "quantity"
// FieldStatus holds the string denoting the status field in the database.
FieldStatus = "status"
2023-10-28 23:12:07 +00:00
// FieldProductCategoryID holds the string denoting the product_category_id field in the database.
FieldProductCategoryID = "product_category_id"
// FieldBusinessID holds the string denoting the business_id field in the database.
FieldBusinessID = "business_id"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
2023-10-27 09:51:58 +00:00
// 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"
2023-10-28 23:12:07 +00:00
// EdgeProductCategories holds the string denoting the product_categories edge name in mutations.
EdgeProductCategories = "product_categories"
// EdgeBusinesses holds the string denoting the businesses edge name in mutations.
EdgeBusinesses = "businesses"
// EdgeUsers holds the string denoting the users edge name in mutations.
EdgeUsers = "users"
2023-10-27 09:51:58 +00:00
// Table holds the table name of the product in the database.
Table = "products"
2023-10-28 23:12:07 +00:00
// ProductCategoriesTable is the table that holds the product_categories relation/edge.
ProductCategoriesTable = "products"
// ProductCategoriesInverseTable is the table name for the ProductCategory entity.
2023-10-27 09:51:58 +00:00
// It exists in this package in order to avoid circular dependency with the "productcategory" package.
2023-10-28 23:12:07 +00:00
ProductCategoriesInverseTable = "product_categories"
// ProductCategoriesColumn is the table column denoting the product_categories relation/edge.
ProductCategoriesColumn = "product_category_id"
// BusinessesTable is the table that holds the businesses relation/edge.
BusinessesTable = "products"
// BusinessesInverseTable is the table name for the Business entity.
// It exists in this package in order to avoid circular dependency with the "business" package.
BusinessesInverseTable = "businesses"
// BusinessesColumn is the table column denoting the businesses relation/edge.
BusinessesColumn = "business_id"
// UsersTable is the table that holds the users relation/edge.
UsersTable = "products"
// UsersInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
UsersInverseTable = "users"
// UsersColumn is the table column denoting the users relation/edge.
UsersColumn = "user_id"
2023-10-27 09:51:58 +00:00
)
// Columns holds all SQL columns for product fields.
var Columns = []string{
FieldID,
FieldName,
2023-10-28 23:12:07 +00:00
FieldSummary,
2023-10-27 09:51:58 +00:00
FieldDescription,
FieldPrice,
FieldOriginalPrice,
FieldQuantity,
FieldStatus,
2023-10-28 23:12:07 +00:00
FieldProductCategoryID,
FieldBusinessID,
FieldUserID,
2023-10-27 09:51:58 +00:00
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 (
// DefaultName holds the default value on creation for the "name" field.
DefaultName string
// DefaultPrice holds the default value on creation for the "price" field.
DefaultPrice float64
// PriceValidator is a validator for the "price" field. It is called by the builders before save.
PriceValidator func(float64) error
// DefaultOriginalPrice holds the default value on creation for the "original_price" field.
DefaultOriginalPrice float64
// OriginalPriceValidator is a validator for the "original_price" field. It is called by the builders before save.
OriginalPriceValidator func(float64) error
// DefaultQuantity holds the default value on creation for the "quantity" field.
DefaultQuantity int
// QuantityValidator is a validator for the "quantity" field. It is called by the builders before save.
QuantityValidator func(int) error
// DefaultStatus holds the default value on creation for the "status" field.
DefaultStatus bool
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt time.Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt 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 Product 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()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
2023-10-28 23:12:07 +00:00
// BySummary orders the results by the summary field.
func BySummary(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSummary, opts...).ToFunc()
}
2023-10-27 09:51:58 +00:00
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByPrice orders the results by the price field.
func ByPrice(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPrice, opts...).ToFunc()
}
// ByOriginalPrice orders the results by the original_price field.
func ByOriginalPrice(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOriginalPrice, opts...).ToFunc()
}
// ByQuantity orders the results by the quantity field.
func ByQuantity(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldQuantity, opts...).ToFunc()
}
// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldStatus, opts...).ToFunc()
}
2023-10-28 23:12:07 +00:00
// ByProductCategoryID orders the results by the product_category_id field.
func ByProductCategoryID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProductCategoryID, opts...).ToFunc()
}
// ByBusinessID orders the results by the business_id field.
func ByBusinessID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldBusinessID, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
2023-10-27 09:51:58 +00:00
// 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()
}
2023-10-28 23:12:07 +00:00
// ByProductCategoriesField orders the results by product_categories field.
func ByProductCategoriesField(field string, opts ...sql.OrderTermOption) OrderOption {
2023-10-27 09:51:58 +00:00
return func(s *sql.Selector) {
2023-10-28 23:12:07 +00:00
sqlgraph.OrderByNeighborTerms(s, newProductCategoriesStep(), sql.OrderByField(field, opts...))
2023-10-27 09:51:58 +00:00
}
}
2023-10-28 23:12:07 +00:00
// ByBusinessesField orders the results by businesses field.
func ByBusinessesField(field string, opts ...sql.OrderTermOption) OrderOption {
2023-10-27 09:51:58 +00:00
return func(s *sql.Selector) {
2023-10-28 23:12:07 +00:00
sqlgraph.OrderByNeighborTerms(s, newBusinessesStep(), sql.OrderByField(field, opts...))
2023-10-27 09:51:58 +00:00
}
}
2023-10-28 23:12:07 +00:00
// ByUsersField orders the results by users field.
func ByUsersField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUsersStep(), sql.OrderByField(field, opts...))
}
}
func newProductCategoriesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProductCategoriesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, ProductCategoriesTable, ProductCategoriesColumn),
)
}
func newBusinessesStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(BusinessesInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, BusinessesTable, BusinessesColumn),
)
}
func newUsersStep() *sqlgraph.Step {
2023-10-27 09:51:58 +00:00
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
2023-10-28 23:12:07 +00:00
sqlgraph.To(UsersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UsersTable, UsersColumn),
2023-10-27 09:51:58 +00:00
)
}