// Code generated by ent, DO NOT EDIT.

package resource

import (
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
)

const (
	// Label holds the string label denoting the resource type in the database.
	Label = "resource"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldAstraID holds the string denoting the astra_id field in the database.
	FieldAstraID = "astra_id"
	// FieldType holds the string denoting the type field in the database.
	FieldType = "type"
	// FieldURI holds the string denoting the uri field in the database.
	FieldURI = "uri"
	// FieldFormat holds the string denoting the format field in the database.
	FieldFormat = "format"
	// FieldMetadata holds the string denoting the metadata field in the database.
	FieldMetadata = "metadata"
	// FieldCompleteness holds the string denoting the completeness field in the database.
	FieldCompleteness = "completeness"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// Table holds the table name of the resource in the database.
	Table = "resources"
)

// Columns holds all SQL columns for resource fields.
var Columns = []string{
	FieldID,
	FieldAstraID,
	FieldType,
	FieldURI,
	FieldFormat,
	FieldMetadata,
	FieldCompleteness,
	FieldCreatedAt,
}

// 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 (
	// AstraIDValidator is a validator for the "astra_id" field. It is called by the builders before save.
	AstraIDValidator func(string) error
	// DefaultType holds the default value on creation for the "type" field.
	DefaultType string
	// DefaultURI holds the default value on creation for the "uri" field.
	DefaultURI string
	// DefaultFormat holds the default value on creation for the "format" field.
	DefaultFormat string
	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
	DefaultCreatedAt func() time.Time
)

// Completeness defines the type for the "completeness" enum field.
type Completeness string

// CompletenessComplete is the default value of the Completeness enum.
const DefaultCompleteness = CompletenessComplete

// Completeness values.
const (
	CompletenessComplete   Completeness = "complete"
	CompletenessIncomplete Completeness = "incomplete"
)

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

// CompletenessValidator is a validator for the "completeness" field enum values. It is called by the builders before save.
func CompletenessValidator(c Completeness) error {
	switch c {
	case CompletenessComplete, CompletenessIncomplete:
		return nil
	default:
		return fmt.Errorf("resource: invalid enum value for completeness field: %q", c)
	}
}

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

// ByAstraID orders the results by the astra_id field.
func ByAstraID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAstraID, opts...).ToFunc()
}

// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldType, opts...).ToFunc()
}

// ByURI orders the results by the uri field.
func ByURI(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldURI, opts...).ToFunc()
}

// ByFormat orders the results by the format field.
func ByFormat(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFormat, opts...).ToFunc()
}

// ByCompleteness orders the results by the completeness field.
func ByCompleteness(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCompleteness, opts...).ToFunc()
}

// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
