// Code generated by ent, DO NOT EDIT.

package piecejointe

import (
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
)

const (
	// Label holds the string label denoting the piecejointe type in the database.
	Label = "piece_jointe"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldObjetID holds the string denoting the objet_id field in the database.
	FieldObjetID = "objet_id"
	// FieldNomFichier holds the string denoting the nom_fichier field in the database.
	FieldNomFichier = "nom_fichier"
	// FieldChemin holds the string denoting the chemin field in the database.
	FieldChemin = "chemin"
	// FieldTypeMime holds the string denoting the type_mime field in the database.
	FieldTypeMime = "type_mime"
	// FieldEstPrincipale holds the string denoting the est_principale field in the database.
	FieldEstPrincipale = "est_principale"
	// FieldCategorie holds the string denoting the categorie field in the database.
	FieldCategorie = "categorie"
	// 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"
	// EdgeObjet holds the string denoting the objet edge name in mutations.
	EdgeObjet = "objet"
	// Table holds the table name of the piecejointe in the database.
	Table = "piece_jointe"
	// ObjetTable is the table that holds the objet relation/edge.
	ObjetTable = "piece_jointe"
	// ObjetInverseTable is the table name for the Objet entity.
	// It exists in this package in order to avoid circular dependency with the "objet" package.
	ObjetInverseTable = "objet"
	// ObjetColumn is the table column denoting the objet relation/edge.
	ObjetColumn = "objet_id"
)

// Columns holds all SQL columns for piecejointe fields.
var Columns = []string{
	FieldID,
	FieldObjetID,
	FieldNomFichier,
	FieldChemin,
	FieldTypeMime,
	FieldEstPrincipale,
	FieldCategorie,
	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 (
	// NomFichierValidator is a validator for the "nom_fichier" field. It is called by the builders before save.
	NomFichierValidator func(string) error
	// CheminValidator is a validator for the "chemin" field. It is called by the builders before save.
	CheminValidator func(string) error
	// TypeMimeValidator is a validator for the "type_mime" field. It is called by the builders before save.
	TypeMimeValidator func(string) error
	// DefaultEstPrincipale holds the default value on creation for the "est_principale" field.
	DefaultEstPrincipale bool
	// 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
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// Categorie defines the type for the "categorie" enum field.
type Categorie string

// CategorieImage is the default value of the Categorie enum.
const DefaultCategorie = CategorieImage

// Categorie values.
const (
	CategorieImage        Categorie = "image"
	CategoriePdfNotice    Categorie = "pdf_notice"
	CategorieMarkdownTuto Categorie = "markdown_tuto"
)

func (c Categorie) String() string {
	return string(c)
}

// CategorieValidator is a validator for the "categorie" field enum values. It is called by the builders before save.
func CategorieValidator(c Categorie) error {
	switch c {
	case CategorieImage, CategoriePdfNotice, CategorieMarkdownTuto:
		return nil
	default:
		return fmt.Errorf("piecejointe: invalid enum value for categorie field: %q", c)
	}
}

// OrderOption defines the ordering options for the PieceJointe 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()
}

// ByObjetID orders the results by the objet_id field.
func ByObjetID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldObjetID, opts...).ToFunc()
}

// ByNomFichier orders the results by the nom_fichier field.
func ByNomFichier(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldNomFichier, opts...).ToFunc()
}

// ByChemin orders the results by the chemin field.
func ByChemin(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldChemin, opts...).ToFunc()
}

// ByTypeMime orders the results by the type_mime field.
func ByTypeMime(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldTypeMime, opts...).ToFunc()
}

// ByEstPrincipale orders the results by the est_principale field.
func ByEstPrincipale(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldEstPrincipale, opts...).ToFunc()
}

// ByCategorie orders the results by the categorie field.
func ByCategorie(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCategorie, 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()
}

// ByObjetField orders the results by objet field.
func ByObjetField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newObjetStep(), sql.OrderByField(field, opts...))
	}
}
func newObjetStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(ObjetInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, ObjetTable, ObjetColumn),
	)
}
