snapshot of https://github.com/ent/ent.git (master, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
490
examples/migration/ent/sessiondevice/mutation.go
Normal file
490
examples/migration/ent/sessiondevice/mutation.go
Normal file
@@ -0,0 +1,490 @@
|
||||
// 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 sessiondevice
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/examples/migration/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Mutation represents an operation that mutates the SessionDevice nodes in the graph.
|
||||
type Mutation struct {
|
||||
op ent.Op
|
||||
typ string
|
||||
ip_address *string
|
||||
user_agent *string
|
||||
location *string
|
||||
created_at *time.Time
|
||||
updated_at *time.Time
|
||||
clearedFields map[string]struct{}
|
||||
sessions map[uuid.UUID]struct{}
|
||||
removedsessions map[uuid.UUID]struct{}
|
||||
clearedsessions bool
|
||||
predicates []predicate.SessionDevice
|
||||
}
|
||||
|
||||
// NewMutation creates a new Mutation for the SessionDevice entity.
|
||||
func NewMutation(op ent.Op) *Mutation {
|
||||
return &Mutation{
|
||||
op: op,
|
||||
typ: "SessionDevice",
|
||||
clearedFields: make(map[string]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
// Predicates returns the list of predicates set on the mutation.
|
||||
func (m *Mutation) Predicates() []predicate.SessionDevice {
|
||||
return m.predicates
|
||||
}
|
||||
|
||||
// SetIPAddress sets the "ip_address" field.
|
||||
func (m *Mutation) SetIPAddress(s string) {
|
||||
m.ip_address = &s
|
||||
}
|
||||
|
||||
// IPAddress returns the value of the "ip_address" field in the mutation.
|
||||
func (m *Mutation) IPAddress() (r string, exists bool) {
|
||||
v := m.ip_address
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetIPAddress resets all changes to the "ip_address" field.
|
||||
func (m *Mutation) ResetIPAddress() {
|
||||
m.ip_address = nil
|
||||
}
|
||||
|
||||
// SetUserAgent sets the "user_agent" field.
|
||||
func (m *Mutation) SetUserAgent(s string) {
|
||||
m.user_agent = &s
|
||||
}
|
||||
|
||||
// UserAgent returns the value of the "user_agent" field in the mutation.
|
||||
func (m *Mutation) UserAgent() (r string, exists bool) {
|
||||
v := m.user_agent
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetUserAgent resets all changes to the "user_agent" field.
|
||||
func (m *Mutation) ResetUserAgent() {
|
||||
m.user_agent = nil
|
||||
}
|
||||
|
||||
// SetLocation sets the "location" field.
|
||||
func (m *Mutation) SetLocation(s string) {
|
||||
m.location = &s
|
||||
}
|
||||
|
||||
// Location returns the value of the "location" field in the mutation.
|
||||
func (m *Mutation) Location() (r string, exists bool) {
|
||||
v := m.location
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetLocation resets all changes to the "location" field.
|
||||
func (m *Mutation) ResetLocation() {
|
||||
m.location = nil
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (m *Mutation) SetCreatedAt(t time.Time) {
|
||||
m.created_at = &t
|
||||
}
|
||||
|
||||
// CreatedAt returns the value of the "created_at" field in the mutation.
|
||||
func (m *Mutation) CreatedAt() (r time.Time, exists bool) {
|
||||
v := m.created_at
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ResetCreatedAt resets all changes to the "created_at" field.
|
||||
func (m *Mutation) ResetCreatedAt() {
|
||||
m.created_at = nil
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (m *Mutation) SetUpdatedAt(t time.Time) {
|
||||
m.updated_at = &t
|
||||
}
|
||||
|
||||
// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
||||
func (m *Mutation) UpdatedAt() (r time.Time, exists bool) {
|
||||
v := m.updated_at
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updated_at" field.
|
||||
func (m *Mutation) ClearUpdatedAt() {
|
||||
m.updated_at = nil
|
||||
m.clearedFields[FieldUpdatedAt] = struct{}{}
|
||||
}
|
||||
|
||||
// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
|
||||
func (m *Mutation) UpdatedAtCleared() bool {
|
||||
_, ok := m.clearedFields[FieldUpdatedAt]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ResetUpdatedAt resets all changes to the "updated_at" field.
|
||||
func (m *Mutation) ResetUpdatedAt() {
|
||||
m.updated_at = nil
|
||||
delete(m.clearedFields, FieldUpdatedAt)
|
||||
}
|
||||
|
||||
// AddSessionIDs adds the "sessions" edge to the Session entity by ids.
|
||||
func (m *Mutation) AddSessionIDs(ids ...uuid.UUID) {
|
||||
if m.sessions == nil {
|
||||
m.sessions = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
m.sessions[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// ClearSessions clears the "sessions" edge to the Session entity.
|
||||
func (m *Mutation) ClearSessions() {
|
||||
m.clearedsessions = true
|
||||
}
|
||||
|
||||
// SessionsCleared reports if the "sessions" edge to the Session entity was cleared.
|
||||
func (m *Mutation) SessionsCleared() bool {
|
||||
return m.clearedsessions
|
||||
}
|
||||
|
||||
// RemoveSessionIDs removes the "sessions" edge to the Session entity by IDs.
|
||||
func (m *Mutation) RemoveSessionIDs(ids ...uuid.UUID) {
|
||||
if m.removedsessions == nil {
|
||||
m.removedsessions = make(map[uuid.UUID]struct{})
|
||||
}
|
||||
for i := range ids {
|
||||
delete(m.sessions, ids[i])
|
||||
m.removedsessions[ids[i]] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// RemovedSessions returns the removed IDs of the "sessions" edge to the Session entity.
|
||||
func (m *Mutation) RemovedSessionsIDs() (ids []uuid.UUID) {
|
||||
for id := range m.removedsessions {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SessionsIDs returns the "sessions" edge IDs in the mutation.
|
||||
func (m *Mutation) SessionsIDs() (ids []uuid.UUID) {
|
||||
for id := range m.sessions {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ResetSessions resets all changes to the "sessions" edge.
|
||||
func (m *Mutation) ResetSessions() {
|
||||
m.sessions = nil
|
||||
m.clearedsessions = false
|
||||
m.removedsessions = nil
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the Mutation builder.
|
||||
func (m *Mutation) Where(ps ...predicate.SessionDevice) {
|
||||
m.predicates = append(m.predicates, ps...)
|
||||
}
|
||||
|
||||
// WhereP appends storage-level predicates to the Mutation builder. Using this method,
|
||||
// users can use type-assertion to append predicates that do not depend on any generated package.
|
||||
func (m *Mutation) WhereP(ps ...func(*sql.Selector)) {
|
||||
p := make([]predicate.SessionDevice, len(ps))
|
||||
for i := range ps {
|
||||
p[i] = ps[i]
|
||||
}
|
||||
m.Where(p...)
|
||||
}
|
||||
|
||||
// Op returns the operation name.
|
||||
func (m *Mutation) Op() ent.Op {
|
||||
return m.op
|
||||
}
|
||||
|
||||
// SetOp allows setting the mutation operation.
|
||||
func (m *Mutation) SetOp(op ent.Op) {
|
||||
m.op = op
|
||||
}
|
||||
|
||||
// Type returns the node type of this mutation (SessionDevice).
|
||||
func (m *Mutation) Type() string {
|
||||
return m.typ
|
||||
}
|
||||
|
||||
// Fields returns all fields that were changed during this mutation. Note that in
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *Mutation) Fields() []string {
|
||||
fields := make([]string, 0, 5)
|
||||
if m.ip_address != nil {
|
||||
fields = append(fields, FieldIPAddress)
|
||||
}
|
||||
if m.user_agent != nil {
|
||||
fields = append(fields, FieldUserAgent)
|
||||
}
|
||||
if m.location != nil {
|
||||
fields = append(fields, FieldLocation)
|
||||
}
|
||||
if m.created_at != nil {
|
||||
fields = append(fields, FieldCreatedAt)
|
||||
}
|
||||
if m.updated_at != nil {
|
||||
fields = append(fields, FieldUpdatedAt)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// Field returns the value of a field with the given name. The second boolean
|
||||
// return value indicates that this field was not set, or was not defined in the
|
||||
// schema.
|
||||
func (m *Mutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case FieldIPAddress:
|
||||
return m.IPAddress()
|
||||
case FieldUserAgent:
|
||||
return m.UserAgent()
|
||||
case FieldLocation:
|
||||
return m.Location()
|
||||
case FieldCreatedAt:
|
||||
return m.CreatedAt()
|
||||
case FieldUpdatedAt:
|
||||
return m.UpdatedAt()
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// OldField returns the old value of the field from the database. An error is
|
||||
// returned if the mutation operation is not UpdateOne, or the query to the
|
||||
// database failed.
|
||||
func (m *Mutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
return nil, fmt.Errorf("unknown SessionDevice field %s", name)
|
||||
}
|
||||
|
||||
// SetField sets the value of a field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *Mutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case FieldIPAddress:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetIPAddress(v)
|
||||
return nil
|
||||
case FieldUserAgent:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUserAgent(v)
|
||||
return nil
|
||||
case FieldLocation:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetLocation(v)
|
||||
return nil
|
||||
case FieldCreatedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetCreatedAt(v)
|
||||
return nil
|
||||
case FieldUpdatedAt:
|
||||
v, ok := value.(time.Time)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUpdatedAt(v)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice field %s", name)
|
||||
}
|
||||
|
||||
// AddedFields returns all numeric fields that were incremented/decremented during
|
||||
// this mutation.
|
||||
func (m *Mutation) AddedFields() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddedField returns the numeric value that was incremented/decremented on a field
|
||||
// with the given name. The second boolean return value indicates that this field
|
||||
// was not set, or was not defined in the schema.
|
||||
func (m *Mutation) AddedField(name string) (ent.Value, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// AddField adds the value to the field with the given name. It returns an error if
|
||||
// the field is not defined in the schema, or if the type mismatched the field
|
||||
// type.
|
||||
func (m *Mutation) AddField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice numeric field %s", name)
|
||||
}
|
||||
|
||||
// ClearedFields returns all nullable fields that were cleared during this
|
||||
// mutation.
|
||||
func (m *Mutation) ClearedFields() []string {
|
||||
var fields []string
|
||||
if m.FieldCleared(FieldUpdatedAt) {
|
||||
fields = append(fields, FieldUpdatedAt)
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||
// cleared in this mutation.
|
||||
func (m *Mutation) FieldCleared(name string) bool {
|
||||
_, ok := m.clearedFields[name]
|
||||
return ok
|
||||
}
|
||||
|
||||
// ClearField clears the value of the field with the given name. It returns an
|
||||
// error if the field is not defined in the schema.
|
||||
func (m *Mutation) ClearField(name string) error {
|
||||
switch name {
|
||||
case FieldUpdatedAt:
|
||||
m.ClearUpdatedAt()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice nullable field %s", name)
|
||||
}
|
||||
|
||||
// ResetField resets all changes in the mutation for the field with the given name.
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *Mutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case FieldIPAddress:
|
||||
m.ResetIPAddress()
|
||||
return nil
|
||||
case FieldUserAgent:
|
||||
m.ResetUserAgent()
|
||||
return nil
|
||||
case FieldLocation:
|
||||
m.ResetLocation()
|
||||
return nil
|
||||
case FieldCreatedAt:
|
||||
m.ResetCreatedAt()
|
||||
return nil
|
||||
case FieldUpdatedAt:
|
||||
m.ResetUpdatedAt()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice field %s", name)
|
||||
}
|
||||
|
||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||
func (m *Mutation) AddedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.sessions != nil {
|
||||
edges = append(edges, EdgeSessions)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
||||
// name in this mutation.
|
||||
func (m *Mutation) AddedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case EdgeSessions:
|
||||
ids := make([]ent.Value, 0, len(m.sessions))
|
||||
for id := range m.sessions {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemovedEdges returns all edge names that were removed in this mutation.
|
||||
func (m *Mutation) RemovedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.removedsessions != nil {
|
||||
edges = append(edges, EdgeSessions)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||
// the given name in this mutation.
|
||||
func (m *Mutation) RemovedIDs(name string) []ent.Value {
|
||||
switch name {
|
||||
case EdgeSessions:
|
||||
ids := make([]ent.Value, 0, len(m.removedsessions))
|
||||
for id := range m.removedsessions {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||
func (m *Mutation) ClearedEdges() []string {
|
||||
edges := make([]string, 0, 1)
|
||||
if m.clearedsessions {
|
||||
edges = append(edges, EdgeSessions)
|
||||
}
|
||||
return edges
|
||||
}
|
||||
|
||||
// EdgeCleared returns a boolean which indicates if the edge with the given name
|
||||
// was cleared in this mutation.
|
||||
func (m *Mutation) EdgeCleared(name string) bool {
|
||||
switch name {
|
||||
case EdgeSessions:
|
||||
return m.clearedsessions
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ClearEdge clears the value of the edge with the given name. It returns an error
|
||||
// if that edge is not defined in the schema.
|
||||
func (m *Mutation) ClearEdge(name string) error {
|
||||
switch name {
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice unique edge %s", name)
|
||||
}
|
||||
|
||||
// ResetEdge resets all changes to the edge with the given name in this mutation.
|
||||
// It returns an error if the edge is not defined in the schema.
|
||||
func (m *Mutation) ResetEdge(name string) error {
|
||||
switch name {
|
||||
case EdgeSessions:
|
||||
m.ResetSessions()
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("unknown SessionDevice edge %s", name)
|
||||
}
|
||||
126
examples/migration/ent/sessiondevice/sessiondevice.go
Normal file
126
examples/migration/ent/sessiondevice/sessiondevice.go
Normal file
@@ -0,0 +1,126 @@
|
||||
// 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 sessiondevice
|
||||
|
||||
import (
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the sessiondevice type in the database.
|
||||
Label = "session_device"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldIPAddress holds the string denoting the ip_address field in the database.
|
||||
FieldIPAddress = "ip_address"
|
||||
// FieldUserAgent holds the string denoting the user_agent field in the database.
|
||||
FieldUserAgent = "user_agent"
|
||||
// FieldLocation holds the string denoting the location field in the database.
|
||||
FieldLocation = "location"
|
||||
// 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"
|
||||
// EdgeSessions holds the string denoting the sessions edge name in mutations.
|
||||
EdgeSessions = "sessions"
|
||||
// Table holds the table name of the sessiondevice in the database.
|
||||
Table = "session_devices"
|
||||
// SessionsTable is the table that holds the sessions relation/edge.
|
||||
SessionsTable = "sessions"
|
||||
// SessionsInverseTable is the table name for the Session entity.
|
||||
// It exists in this package in order to avoid circular dependency with the "session" package.
|
||||
SessionsInverseTable = "sessions"
|
||||
// SessionsColumn is the table column denoting the sessions relation/edge.
|
||||
SessionsColumn = "device_id"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for sessiondevice fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldIPAddress,
|
||||
FieldUserAgent,
|
||||
FieldLocation,
|
||||
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 (
|
||||
// IPAddressValidator is a validator for the "ip_address" field. It is called by the builders before save.
|
||||
IPAddressValidator func(string) error
|
||||
// UserAgentValidator is a validator for the "user_agent" field. It is called by the builders before save.
|
||||
UserAgentValidator func(string) error
|
||||
// LocationValidator is a validator for the "location" field. It is called by the builders before save.
|
||||
LocationValidator func(string) error
|
||||
// DefaultID holds the default value on creation for the "id" field.
|
||||
DefaultID func() uuid.UUID
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the SessionDevice 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()
|
||||
}
|
||||
|
||||
// ByIPAddress orders the results by the ip_address field.
|
||||
func ByIPAddress(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIPAddress, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUserAgent orders the results by the user_agent field.
|
||||
func ByUserAgent(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserAgent, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLocation orders the results by the location field.
|
||||
func ByLocation(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLocation, 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()
|
||||
}
|
||||
|
||||
// BySessionsCount orders the results by sessions count.
|
||||
func BySessionsCount(opts ...sql.OrderTermOption) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborsCount(s, newSessionsStep(), opts...)
|
||||
}
|
||||
}
|
||||
|
||||
// BySessions orders the results by sessions terms.
|
||||
func BySessions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
|
||||
return func(s *sql.Selector) {
|
||||
sqlgraph.OrderByNeighborTerms(s, newSessionsStep(), append([]sql.OrderTerm{term}, terms...)...)
|
||||
}
|
||||
}
|
||||
func newSessionsStep() *sqlgraph.Step {
|
||||
return sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(SessionsInverseTable, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn),
|
||||
)
|
||||
}
|
||||
409
examples/migration/ent/sessiondevice/where.go
Normal file
409
examples/migration/ent/sessiondevice/where.go
Normal file
@@ -0,0 +1,409 @@
|
||||
// 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 sessiondevice
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/examples/migration/ent/predicate"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ID filters vertices based on their ID field.
|
||||
func ID(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDEQ applies the EQ predicate on the ID field.
|
||||
func IDEQ(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDNEQ applies the NEQ predicate on the ID field.
|
||||
func IDNEQ(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldID, id))
|
||||
}
|
||||
|
||||
// IDIn applies the In predicate on the ID field.
|
||||
func IDIn(ids ...uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDNotIn applies the NotIn predicate on the ID field.
|
||||
func IDNotIn(ids ...uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldID, ids...))
|
||||
}
|
||||
|
||||
// IDGT applies the GT predicate on the ID field.
|
||||
func IDGT(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDGTE applies the GTE predicate on the ID field.
|
||||
func IDGTE(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLT applies the LT predicate on the ID field.
|
||||
func IDLT(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldID, id))
|
||||
}
|
||||
|
||||
// IDLTE applies the LTE predicate on the ID field.
|
||||
func IDLTE(id uuid.UUID) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// IPAddress applies equality check predicate on the "ip_address" field. It's identical to IPAddressEQ.
|
||||
func IPAddress(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// UserAgent applies equality check predicate on the "user_agent" field. It's identical to UserAgentEQ.
|
||||
func UserAgent(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// Location applies equality check predicate on the "location" field. It's identical to LocationEQ.
|
||||
func Location(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
|
||||
func UpdatedAt(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// IPAddressEQ applies the EQ predicate on the "ip_address" field.
|
||||
func IPAddressEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressNEQ applies the NEQ predicate on the "ip_address" field.
|
||||
func IPAddressNEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressIn applies the In predicate on the "ip_address" field.
|
||||
func IPAddressIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldIPAddress, vs...))
|
||||
}
|
||||
|
||||
// IPAddressNotIn applies the NotIn predicate on the "ip_address" field.
|
||||
func IPAddressNotIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldIPAddress, vs...))
|
||||
}
|
||||
|
||||
// IPAddressGT applies the GT predicate on the "ip_address" field.
|
||||
func IPAddressGT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressGTE applies the GTE predicate on the "ip_address" field.
|
||||
func IPAddressGTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressLT applies the LT predicate on the "ip_address" field.
|
||||
func IPAddressLT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressLTE applies the LTE predicate on the "ip_address" field.
|
||||
func IPAddressLTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressContains applies the Contains predicate on the "ip_address" field.
|
||||
func IPAddressContains(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContains(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressHasPrefix applies the HasPrefix predicate on the "ip_address" field.
|
||||
func IPAddressHasPrefix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasPrefix(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressHasSuffix applies the HasSuffix predicate on the "ip_address" field.
|
||||
func IPAddressHasSuffix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasSuffix(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressEqualFold applies the EqualFold predicate on the "ip_address" field.
|
||||
func IPAddressEqualFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEqualFold(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressContainsFold applies the ContainsFold predicate on the "ip_address" field.
|
||||
func IPAddressContainsFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContainsFold(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// UserAgentEQ applies the EQ predicate on the "user_agent" field.
|
||||
func UserAgentEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentNEQ applies the NEQ predicate on the "user_agent" field.
|
||||
func UserAgentNEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentIn applies the In predicate on the "user_agent" field.
|
||||
func UserAgentIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldUserAgent, vs...))
|
||||
}
|
||||
|
||||
// UserAgentNotIn applies the NotIn predicate on the "user_agent" field.
|
||||
func UserAgentNotIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldUserAgent, vs...))
|
||||
}
|
||||
|
||||
// UserAgentGT applies the GT predicate on the "user_agent" field.
|
||||
func UserAgentGT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentGTE applies the GTE predicate on the "user_agent" field.
|
||||
func UserAgentGTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentLT applies the LT predicate on the "user_agent" field.
|
||||
func UserAgentLT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentLTE applies the LTE predicate on the "user_agent" field.
|
||||
func UserAgentLTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentContains applies the Contains predicate on the "user_agent" field.
|
||||
func UserAgentContains(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContains(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentHasPrefix applies the HasPrefix predicate on the "user_agent" field.
|
||||
func UserAgentHasPrefix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasPrefix(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentHasSuffix applies the HasSuffix predicate on the "user_agent" field.
|
||||
func UserAgentHasSuffix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasSuffix(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentEqualFold applies the EqualFold predicate on the "user_agent" field.
|
||||
func UserAgentEqualFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEqualFold(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentContainsFold applies the ContainsFold predicate on the "user_agent" field.
|
||||
func UserAgentContainsFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContainsFold(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// LocationEQ applies the EQ predicate on the "location" field.
|
||||
func LocationEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationNEQ applies the NEQ predicate on the "location" field.
|
||||
func LocationNEQ(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationIn applies the In predicate on the "location" field.
|
||||
func LocationIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldLocation, vs...))
|
||||
}
|
||||
|
||||
// LocationNotIn applies the NotIn predicate on the "location" field.
|
||||
func LocationNotIn(vs ...string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldLocation, vs...))
|
||||
}
|
||||
|
||||
// LocationGT applies the GT predicate on the "location" field.
|
||||
func LocationGT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationGTE applies the GTE predicate on the "location" field.
|
||||
func LocationGTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationLT applies the LT predicate on the "location" field.
|
||||
func LocationLT(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationLTE applies the LTE predicate on the "location" field.
|
||||
func LocationLTE(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationContains applies the Contains predicate on the "location" field.
|
||||
func LocationContains(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContains(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationHasPrefix applies the HasPrefix predicate on the "location" field.
|
||||
func LocationHasPrefix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasPrefix(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationHasSuffix applies the HasSuffix predicate on the "location" field.
|
||||
func LocationHasSuffix(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldHasSuffix(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationEqualFold applies the EqualFold predicate on the "location" field.
|
||||
func LocationEqualFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEqualFold(FieldLocation, v))
|
||||
}
|
||||
|
||||
// LocationContainsFold applies the ContainsFold predicate on the "location" field.
|
||||
func LocationContainsFold(v string) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldContainsFold(FieldLocation, v))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
|
||||
func CreatedAtNEQ(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||
func CreatedAtIn(vs ...time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||
func CreatedAtNotIn(vs ...time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldCreatedAt, vs...))
|
||||
}
|
||||
|
||||
// CreatedAtGT applies the GT predicate on the "created_at" field.
|
||||
func CreatedAtGT(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
|
||||
func CreatedAtGTE(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLT applies the LT predicate on the "created_at" field.
|
||||
func CreatedAtLT(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
|
||||
func CreatedAtLTE(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldCreatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
|
||||
func UpdatedAtEQ(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
|
||||
func UpdatedAtNEQ(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNEQ(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||
func UpdatedAtIn(vs ...time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||
func UpdatedAtNotIn(vs ...time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotIn(FieldUpdatedAt, vs...))
|
||||
}
|
||||
|
||||
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
|
||||
func UpdatedAtGT(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
|
||||
func UpdatedAtGTE(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldGTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
|
||||
func UpdatedAtLT(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLT(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
|
||||
func UpdatedAtLTE(v time.Time) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldLTE(FieldUpdatedAt, v))
|
||||
}
|
||||
|
||||
// UpdatedAtIsNil applies the IsNil predicate on the "updated_at" field.
|
||||
func UpdatedAtIsNil() predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldIsNull(FieldUpdatedAt))
|
||||
}
|
||||
|
||||
// UpdatedAtNotNil applies the NotNil predicate on the "updated_at" field.
|
||||
func UpdatedAtNotNil() predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.FieldNotNull(FieldUpdatedAt))
|
||||
}
|
||||
|
||||
// HasSessions applies the HasEdge predicate on the "sessions" edge.
|
||||
func HasSessions() predicate.SessionDevice {
|
||||
return predicate.SessionDevice(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, SessionsTable, SessionsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
})
|
||||
}
|
||||
|
||||
// HasSessionsWith applies the HasEdge predicate on the "sessions" edge with a given conditions (other predicates).
|
||||
func HasSessionsWith(preds ...predicate.Session) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(func(s *sql.Selector) {
|
||||
step := newSessionsStep()
|
||||
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.SessionDevice) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.SessionDevice) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.SessionDevice) predicate.SessionDevice {
|
||||
return predicate.SessionDevice(sql.NotPredicates(p))
|
||||
}
|
||||
Reference in New Issue
Block a user