ent seteup

This commit is contained in:
2024-11-10 14:52:33 +05:30
parent 45c318b897
commit b0db98452a
78 changed files with 21469 additions and 36 deletions

View File

@@ -0,0 +1,123 @@
// Code generated by ent, DO NOT EDIT.
package usersession
import (
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the usersession type in the database.
Label = "user_session"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// 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"
// FieldInvalidated holds the string denoting the invalidated field in the database.
FieldInvalidated = "invalidated"
// FieldUserAgent holds the string denoting the user_agent field in the database.
FieldUserAgent = "user_agent"
// FieldIP holds the string denoting the ip field in the database.
FieldIP = "ip"
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser = "user"
// Table holds the table name of the usersession in the database.
Table = "user_sessions"
// UserTable is the table that holds the user relation/edge.
UserTable = "user_sessions"
// UserInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
UserInverseTable = "users"
// UserColumn is the table column denoting the user relation/edge.
UserColumn = "user_id"
)
// Columns holds all SQL columns for usersession fields.
var Columns = []string{
FieldID,
FieldIssuedAt,
FieldExpiresAt,
FieldInvalidated,
FieldUserAgent,
FieldIP,
}
// ForeignKeys holds the SQL foreign-keys that are owned by the "user_sessions"
// table and are not defined as standalone fields in the schema.
var ForeignKeys = []string{
"user_id",
}
// 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
}
}
for i := range ForeignKeys {
if column == ForeignKeys[i] {
return true
}
}
return false
}
var (
// DefaultInvalidated holds the default value on creation for the "invalidated" field.
DefaultInvalidated bool
// UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
UserAgentValidator func(string) error
// IPValidator is a validator for the "ip" field. It is called by the builders before save.
IPValidator func(string) error
)
// OrderOption defines the ordering options for the UserSession 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()
}
// 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()
}
// ByInvalidated orders the results by the invalidated field.
func ByInvalidated(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldInvalidated, opts...).ToFunc()
}
// ByUserAgent orders the results by the user_agent field.
func ByUserAgent(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserAgent, opts...).ToFunc()
}
// ByIP orders the results by the ip field.
func ByIP(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIP, opts...).ToFunc()
}
// ByUserField orders the results by user field.
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
}
}
func newUserStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UserInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
}

349
db/ent/usersession/where.go Normal file
View File

@@ -0,0 +1,349 @@
// Code generated by ent, DO NOT EDIT.
package usersession
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"gitserver.in/patialtech/rano/db/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.UserSession {
return predicate.UserSession(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.UserSession {
return predicate.UserSession(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.UserSession {
return predicate.UserSession(sql.FieldLTE(FieldID, id))
}
// IssuedAt applies equality check predicate on the "issued_at" field. It's identical to IssuedAtEQ.
func IssuedAt(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldIssuedAt, v))
}
// ExpiresAt applies equality check predicate on the "expires_at" field. It's identical to ExpiresAtEQ.
func ExpiresAt(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldExpiresAt, v))
}
// Invalidated applies equality check predicate on the "invalidated" field. It's identical to InvalidatedEQ.
func Invalidated(v bool) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldInvalidated, v))
}
// UserAgent applies equality check predicate on the "user_agent" field. It's identical to UserAgentEQ.
func UserAgent(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v))
}
// IP applies equality check predicate on the "ip" field. It's identical to IPEQ.
func IP(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldIP, v))
}
// IssuedAtEQ applies the EQ predicate on the "issued_at" field.
func IssuedAtEQ(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldIssuedAt, v))
}
// IssuedAtNEQ applies the NEQ predicate on the "issued_at" field.
func IssuedAtNEQ(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldIssuedAt, v))
}
// IssuedAtIn applies the In predicate on the "issued_at" field.
func IssuedAtIn(vs ...time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldIn(FieldIssuedAt, vs...))
}
// IssuedAtNotIn applies the NotIn predicate on the "issued_at" field.
func IssuedAtNotIn(vs ...time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldNotIn(FieldIssuedAt, vs...))
}
// IssuedAtGT applies the GT predicate on the "issued_at" field.
func IssuedAtGT(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldGT(FieldIssuedAt, v))
}
// IssuedAtGTE applies the GTE predicate on the "issued_at" field.
func IssuedAtGTE(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldGTE(FieldIssuedAt, v))
}
// IssuedAtLT applies the LT predicate on the "issued_at" field.
func IssuedAtLT(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldLT(FieldIssuedAt, v))
}
// IssuedAtLTE applies the LTE predicate on the "issued_at" field.
func IssuedAtLTE(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldLTE(FieldIssuedAt, v))
}
// ExpiresAtEQ applies the EQ predicate on the "expires_at" field.
func ExpiresAtEQ(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldExpiresAt, v))
}
// ExpiresAtNEQ applies the NEQ predicate on the "expires_at" field.
func ExpiresAtNEQ(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldExpiresAt, v))
}
// ExpiresAtIn applies the In predicate on the "expires_at" field.
func ExpiresAtIn(vs ...time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldIn(FieldExpiresAt, vs...))
}
// ExpiresAtNotIn applies the NotIn predicate on the "expires_at" field.
func ExpiresAtNotIn(vs ...time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldNotIn(FieldExpiresAt, vs...))
}
// ExpiresAtGT applies the GT predicate on the "expires_at" field.
func ExpiresAtGT(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldGT(FieldExpiresAt, v))
}
// ExpiresAtGTE applies the GTE predicate on the "expires_at" field.
func ExpiresAtGTE(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldGTE(FieldExpiresAt, v))
}
// ExpiresAtLT applies the LT predicate on the "expires_at" field.
func ExpiresAtLT(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldLT(FieldExpiresAt, v))
}
// ExpiresAtLTE applies the LTE predicate on the "expires_at" field.
func ExpiresAtLTE(v time.Time) predicate.UserSession {
return predicate.UserSession(sql.FieldLTE(FieldExpiresAt, v))
}
// InvalidatedEQ applies the EQ predicate on the "invalidated" field.
func InvalidatedEQ(v bool) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldInvalidated, v))
}
// InvalidatedNEQ applies the NEQ predicate on the "invalidated" field.
func InvalidatedNEQ(v bool) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldInvalidated, v))
}
// InvalidatedIsNil applies the IsNil predicate on the "invalidated" field.
func InvalidatedIsNil() predicate.UserSession {
return predicate.UserSession(sql.FieldIsNull(FieldInvalidated))
}
// InvalidatedNotNil applies the NotNil predicate on the "invalidated" field.
func InvalidatedNotNil() predicate.UserSession {
return predicate.UserSession(sql.FieldNotNull(FieldInvalidated))
}
// UserAgentEQ applies the EQ predicate on the "user_agent" field.
func UserAgentEQ(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldUserAgent, v))
}
// UserAgentNEQ applies the NEQ predicate on the "user_agent" field.
func UserAgentNEQ(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldUserAgent, v))
}
// UserAgentIn applies the In predicate on the "user_agent" field.
func UserAgentIn(vs ...string) predicate.UserSession {
return predicate.UserSession(sql.FieldIn(FieldUserAgent, vs...))
}
// UserAgentNotIn applies the NotIn predicate on the "user_agent" field.
func UserAgentNotIn(vs ...string) predicate.UserSession {
return predicate.UserSession(sql.FieldNotIn(FieldUserAgent, vs...))
}
// UserAgentGT applies the GT predicate on the "user_agent" field.
func UserAgentGT(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldGT(FieldUserAgent, v))
}
// UserAgentGTE applies the GTE predicate on the "user_agent" field.
func UserAgentGTE(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldGTE(FieldUserAgent, v))
}
// UserAgentLT applies the LT predicate on the "user_agent" field.
func UserAgentLT(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldLT(FieldUserAgent, v))
}
// UserAgentLTE applies the LTE predicate on the "user_agent" field.
func UserAgentLTE(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldLTE(FieldUserAgent, v))
}
// UserAgentContains applies the Contains predicate on the "user_agent" field.
func UserAgentContains(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldContains(FieldUserAgent, v))
}
// UserAgentHasPrefix applies the HasPrefix predicate on the "user_agent" field.
func UserAgentHasPrefix(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldHasPrefix(FieldUserAgent, v))
}
// UserAgentHasSuffix applies the HasSuffix predicate on the "user_agent" field.
func UserAgentHasSuffix(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldHasSuffix(FieldUserAgent, v))
}
// UserAgentEqualFold applies the EqualFold predicate on the "user_agent" field.
func UserAgentEqualFold(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEqualFold(FieldUserAgent, v))
}
// UserAgentContainsFold applies the ContainsFold predicate on the "user_agent" field.
func UserAgentContainsFold(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldContainsFold(FieldUserAgent, v))
}
// IPEQ applies the EQ predicate on the "ip" field.
func IPEQ(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEQ(FieldIP, v))
}
// IPNEQ applies the NEQ predicate on the "ip" field.
func IPNEQ(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldNEQ(FieldIP, v))
}
// IPIn applies the In predicate on the "ip" field.
func IPIn(vs ...string) predicate.UserSession {
return predicate.UserSession(sql.FieldIn(FieldIP, vs...))
}
// IPNotIn applies the NotIn predicate on the "ip" field.
func IPNotIn(vs ...string) predicate.UserSession {
return predicate.UserSession(sql.FieldNotIn(FieldIP, vs...))
}
// IPGT applies the GT predicate on the "ip" field.
func IPGT(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldGT(FieldIP, v))
}
// IPGTE applies the GTE predicate on the "ip" field.
func IPGTE(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldGTE(FieldIP, v))
}
// IPLT applies the LT predicate on the "ip" field.
func IPLT(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldLT(FieldIP, v))
}
// IPLTE applies the LTE predicate on the "ip" field.
func IPLTE(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldLTE(FieldIP, v))
}
// IPContains applies the Contains predicate on the "ip" field.
func IPContains(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldContains(FieldIP, v))
}
// IPHasPrefix applies the HasPrefix predicate on the "ip" field.
func IPHasPrefix(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldHasPrefix(FieldIP, v))
}
// IPHasSuffix applies the HasSuffix predicate on the "ip" field.
func IPHasSuffix(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldHasSuffix(FieldIP, v))
}
// IPEqualFold applies the EqualFold predicate on the "ip" field.
func IPEqualFold(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldEqualFold(FieldIP, v))
}
// IPContainsFold applies the ContainsFold predicate on the "ip" field.
func IPContainsFold(v string) predicate.UserSession {
return predicate.UserSession(sql.FieldContainsFold(FieldIP, v))
}
// HasUser applies the HasEdge predicate on the "user" edge.
func HasUser() predicate.UserSession {
return predicate.UserSession(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasUserWith applies the HasEdge predicate on the "user" edge with a given conditions (other predicates).
func HasUserWith(preds ...predicate.User) predicate.UserSession {
return predicate.UserSession(func(s *sql.Selector) {
step := newUserStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// And groups predicates with the AND operator between them.
func And(predicates ...predicate.UserSession) predicate.UserSession {
return predicate.UserSession(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.UserSession) predicate.UserSession {
return predicate.UserSession(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.UserSession) predicate.UserSession {
return predicate.UserSession(sql.NotPredicates(p))
}