// 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 session import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "github.com/google/uuid" ) const ( // Label holds the string label denoting the session type in the database. Label = "session" // FieldID holds the string denoting the id field in the database. FieldID = "id" // FieldActive holds the string denoting the active field in the database. FieldActive = "active" // FieldIssuedAt holds the string denoting the issued_at field in the database. FieldIssuedAt = "issued_at" // FieldExpiresAt holds the string denoting the expires_at field in the database. FieldExpiresAt = "expires_at" // FieldToken holds the string denoting the token field in the database. FieldToken = "token" // FieldMethod holds the string denoting the method field in the database. FieldMethod = "method" // FieldDeviceID holds the string denoting the device_id field in the database. FieldDeviceID = "device_id" // EdgeDevice holds the string denoting the device edge name in mutations. EdgeDevice = "device" // Table holds the table name of the session in the database. Table = "sessions" // DeviceTable is the table that holds the device relation/edge. DeviceTable = "sessions" // DeviceInverseTable is the table name for the SessionDevice entity. // It exists in this package in order to avoid circular dependency with the "sessiondevice" package. DeviceInverseTable = "session_devices" // DeviceColumn is the table column denoting the device relation/edge. DeviceColumn = "device_id" ) // Columns holds all SQL columns for session fields. var Columns = []string{ FieldID, FieldActive, FieldIssuedAt, FieldExpiresAt, FieldToken, FieldMethod, FieldDeviceID, } // 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 ( // DefaultActive holds the default value on creation for the "active" field. DefaultActive bool // DefaultID holds the default value on creation for the "id" field. DefaultID func() uuid.UUID ) // OrderOption defines the ordering options for the Session 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() } // ByActive orders the results by the active field. func ByActive(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldActive, opts...).ToFunc() } // ByIssuedAt orders the results by the issued_at field. func ByIssuedAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldIssuedAt, opts...).ToFunc() } // ByExpiresAt orders the results by the expires_at field. func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldExpiresAt, opts...).ToFunc() } // ByToken orders the results by the token field. func ByToken(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldToken, opts...).ToFunc() } // ByDeviceID orders the results by the device_id field. func ByDeviceID(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDeviceID, opts...).ToFunc() } // ByDeviceField orders the results by device field. func ByDeviceField(field string, opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { sqlgraph.OrderByNeighborTerms(s, newDeviceStep(), sql.OrderByField(field, opts...)) } } func newDeviceStep() *sqlgraph.Step { return sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.To(DeviceInverseTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, DeviceTable, DeviceColumn), ) }