Commit e9de839d authored by IanShaw027's avatar IanShaw027
Browse files

feat: rebuild auth identity foundation flow

parent fbd0a2e3
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/user"
)
// AuthIdentity is the model entity for the AuthIdentity schema.
type AuthIdentity struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// UserID holds the value of the "user_id" field.
UserID int64 `json:"user_id,omitempty"`
// ProviderType holds the value of the "provider_type" field.
ProviderType string `json:"provider_type,omitempty"`
// ProviderKey holds the value of the "provider_key" field.
ProviderKey string `json:"provider_key,omitempty"`
// ProviderSubject holds the value of the "provider_subject" field.
ProviderSubject string `json:"provider_subject,omitempty"`
// VerifiedAt holds the value of the "verified_at" field.
VerifiedAt *time.Time `json:"verified_at,omitempty"`
// Issuer holds the value of the "issuer" field.
Issuer *string `json:"issuer,omitempty"`
// Metadata holds the value of the "metadata" field.
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AuthIdentityQuery when eager-loading is set.
Edges AuthIdentityEdges `json:"edges"`
selectValues sql.SelectValues
}
// AuthIdentityEdges holds the relations/edges for other nodes in the graph.
type AuthIdentityEdges struct {
// User holds the value of the user edge.
User *User `json:"user,omitempty"`
// Channels holds the value of the channels edge.
Channels []*AuthIdentityChannel `json:"channels,omitempty"`
// AdoptionDecisions holds the value of the adoption_decisions edge.
AdoptionDecisions []*IdentityAdoptionDecision `json:"adoption_decisions,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [3]bool
}
// UserOrErr returns the User value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AuthIdentityEdges) UserOrErr() (*User, error) {
if e.User != nil {
return e.User, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "user"}
}
// ChannelsOrErr returns the Channels value or an error if the edge
// was not loaded in eager-loading.
func (e AuthIdentityEdges) ChannelsOrErr() ([]*AuthIdentityChannel, error) {
if e.loadedTypes[1] {
return e.Channels, nil
}
return nil, &NotLoadedError{edge: "channels"}
}
// AdoptionDecisionsOrErr returns the AdoptionDecisions value or an error if the edge
// was not loaded in eager-loading.
func (e AuthIdentityEdges) AdoptionDecisionsOrErr() ([]*IdentityAdoptionDecision, error) {
if e.loadedTypes[2] {
return e.AdoptionDecisions, nil
}
return nil, &NotLoadedError{edge: "adoption_decisions"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AuthIdentity) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case authidentity.FieldMetadata:
values[i] = new([]byte)
case authidentity.FieldID, authidentity.FieldUserID:
values[i] = new(sql.NullInt64)
case authidentity.FieldProviderType, authidentity.FieldProviderKey, authidentity.FieldProviderSubject, authidentity.FieldIssuer:
values[i] = new(sql.NullString)
case authidentity.FieldCreatedAt, authidentity.FieldUpdatedAt, authidentity.FieldVerifiedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the AuthIdentity fields.
func (_m *AuthIdentity) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case authidentity.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case authidentity.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case authidentity.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case authidentity.FieldUserID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
_m.UserID = value.Int64
}
case authidentity.FieldProviderType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field provider_type", values[i])
} else if value.Valid {
_m.ProviderType = value.String
}
case authidentity.FieldProviderKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field provider_key", values[i])
} else if value.Valid {
_m.ProviderKey = value.String
}
case authidentity.FieldProviderSubject:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field provider_subject", values[i])
} else if value.Valid {
_m.ProviderSubject = value.String
}
case authidentity.FieldVerifiedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field verified_at", values[i])
} else if value.Valid {
_m.VerifiedAt = new(time.Time)
*_m.VerifiedAt = value.Time
}
case authidentity.FieldIssuer:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field issuer", values[i])
} else if value.Valid {
_m.Issuer = new(string)
*_m.Issuer = value.String
}
case authidentity.FieldMetadata:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field metadata", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Metadata); err != nil {
return fmt.Errorf("unmarshal field metadata: %w", err)
}
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the AuthIdentity.
// This includes values selected through modifiers, order, etc.
func (_m *AuthIdentity) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryUser queries the "user" edge of the AuthIdentity entity.
func (_m *AuthIdentity) QueryUser() *UserQuery {
return NewAuthIdentityClient(_m.config).QueryUser(_m)
}
// QueryChannels queries the "channels" edge of the AuthIdentity entity.
func (_m *AuthIdentity) QueryChannels() *AuthIdentityChannelQuery {
return NewAuthIdentityClient(_m.config).QueryChannels(_m)
}
// QueryAdoptionDecisions queries the "adoption_decisions" edge of the AuthIdentity entity.
func (_m *AuthIdentity) QueryAdoptionDecisions() *IdentityAdoptionDecisionQuery {
return NewAuthIdentityClient(_m.config).QueryAdoptionDecisions(_m)
}
// Update returns a builder for updating this AuthIdentity.
// Note that you need to call AuthIdentity.Unwrap() before calling this method if this AuthIdentity
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *AuthIdentity) Update() *AuthIdentityUpdateOne {
return NewAuthIdentityClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the AuthIdentity entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *AuthIdentity) Unwrap() *AuthIdentity {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: AuthIdentity is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *AuthIdentity) String() string {
var builder strings.Builder
builder.WriteString("AuthIdentity(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
builder.WriteString(", ")
builder.WriteString("provider_type=")
builder.WriteString(_m.ProviderType)
builder.WriteString(", ")
builder.WriteString("provider_key=")
builder.WriteString(_m.ProviderKey)
builder.WriteString(", ")
builder.WriteString("provider_subject=")
builder.WriteString(_m.ProviderSubject)
builder.WriteString(", ")
if v := _m.VerifiedAt; v != nil {
builder.WriteString("verified_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
if v := _m.Issuer; v != nil {
builder.WriteString("issuer=")
builder.WriteString(*v)
}
builder.WriteString(", ")
builder.WriteString("metadata=")
builder.WriteString(fmt.Sprintf("%v", _m.Metadata))
builder.WriteByte(')')
return builder.String()
}
// AuthIdentities is a parsable slice of AuthIdentity.
type AuthIdentities []*AuthIdentity
// Code generated by ent, DO NOT EDIT.
package authidentity
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the authidentity type in the database.
Label = "auth_identity"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// 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"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldProviderType holds the string denoting the provider_type field in the database.
FieldProviderType = "provider_type"
// FieldProviderKey holds the string denoting the provider_key field in the database.
FieldProviderKey = "provider_key"
// FieldProviderSubject holds the string denoting the provider_subject field in the database.
FieldProviderSubject = "provider_subject"
// FieldVerifiedAt holds the string denoting the verified_at field in the database.
FieldVerifiedAt = "verified_at"
// FieldIssuer holds the string denoting the issuer field in the database.
FieldIssuer = "issuer"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// EdgeUser holds the string denoting the user edge name in mutations.
EdgeUser = "user"
// EdgeChannels holds the string denoting the channels edge name in mutations.
EdgeChannels = "channels"
// EdgeAdoptionDecisions holds the string denoting the adoption_decisions edge name in mutations.
EdgeAdoptionDecisions = "adoption_decisions"
// Table holds the table name of the authidentity in the database.
Table = "auth_identities"
// UserTable is the table that holds the user relation/edge.
UserTable = "auth_identities"
// 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"
// ChannelsTable is the table that holds the channels relation/edge.
ChannelsTable = "auth_identity_channels"
// ChannelsInverseTable is the table name for the AuthIdentityChannel entity.
// It exists in this package in order to avoid circular dependency with the "authidentitychannel" package.
ChannelsInverseTable = "auth_identity_channels"
// ChannelsColumn is the table column denoting the channels relation/edge.
ChannelsColumn = "identity_id"
// AdoptionDecisionsTable is the table that holds the adoption_decisions relation/edge.
AdoptionDecisionsTable = "identity_adoption_decisions"
// AdoptionDecisionsInverseTable is the table name for the IdentityAdoptionDecision entity.
// It exists in this package in order to avoid circular dependency with the "identityadoptiondecision" package.
AdoptionDecisionsInverseTable = "identity_adoption_decisions"
// AdoptionDecisionsColumn is the table column denoting the adoption_decisions relation/edge.
AdoptionDecisionsColumn = "identity_id"
)
// Columns holds all SQL columns for authidentity fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldUserID,
FieldProviderType,
FieldProviderKey,
FieldProviderSubject,
FieldVerifiedAt,
FieldIssuer,
FieldMetadata,
}
// 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 (
// 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
// ProviderTypeValidator is a validator for the "provider_type" field. It is called by the builders before save.
ProviderTypeValidator func(string) error
// ProviderKeyValidator is a validator for the "provider_key" field. It is called by the builders before save.
ProviderKeyValidator func(string) error
// ProviderSubjectValidator is a validator for the "provider_subject" field. It is called by the builders before save.
ProviderSubjectValidator func(string) error
// DefaultMetadata holds the default value on creation for the "metadata" field.
DefaultMetadata func() map[string]interface{}
)
// OrderOption defines the ordering options for the AuthIdentity 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()
}
// 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()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByProviderType orders the results by the provider_type field.
func ByProviderType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProviderType, opts...).ToFunc()
}
// ByProviderKey orders the results by the provider_key field.
func ByProviderKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProviderKey, opts...).ToFunc()
}
// ByProviderSubject orders the results by the provider_subject field.
func ByProviderSubject(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProviderSubject, opts...).ToFunc()
}
// ByVerifiedAt orders the results by the verified_at field.
func ByVerifiedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldVerifiedAt, opts...).ToFunc()
}
// ByIssuer orders the results by the issuer field.
func ByIssuer(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIssuer, 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...))
}
}
// ByChannelsCount orders the results by channels count.
func ByChannelsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newChannelsStep(), opts...)
}
}
// ByChannels orders the results by channels terms.
func ByChannels(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newChannelsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByAdoptionDecisionsCount orders the results by adoption_decisions count.
func ByAdoptionDecisionsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newAdoptionDecisionsStep(), opts...)
}
}
// ByAdoptionDecisions orders the results by adoption_decisions terms.
func ByAdoptionDecisions(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newAdoptionDecisionsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newUserStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UserInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
)
}
func newChannelsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ChannelsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChannelsTable, ChannelsColumn),
)
}
func newAdoptionDecisionsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(AdoptionDecisionsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AdoptionDecisionsTable, AdoptionDecisionsColumn),
)
}
// Code generated by ent, DO NOT EDIT.
package authidentity
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(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.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldUpdatedAt, v))
}
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
func UserID(v int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldUserID, v))
}
// ProviderType applies equality check predicate on the "provider_type" field. It's identical to ProviderTypeEQ.
func ProviderType(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderType, v))
}
// ProviderKey applies equality check predicate on the "provider_key" field. It's identical to ProviderKeyEQ.
func ProviderKey(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderKey, v))
}
// ProviderSubject applies equality check predicate on the "provider_subject" field. It's identical to ProviderSubjectEQ.
func ProviderSubject(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderSubject, v))
}
// VerifiedAt applies equality check predicate on the "verified_at" field. It's identical to VerifiedAtEQ.
func VerifiedAt(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldVerifiedAt, v))
}
// Issuer applies equality check predicate on the "issuer" field. It's identical to IssuerEQ.
func Issuer(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldIssuer, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldUpdatedAt, v))
}
// UserIDEQ applies the EQ predicate on the "user_id" field.
func UserIDEQ(v int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldUserID, v))
}
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
func UserIDNEQ(v int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldUserID, v))
}
// UserIDIn applies the In predicate on the "user_id" field.
func UserIDIn(vs ...int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldUserID, vs...))
}
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
func UserIDNotIn(vs ...int64) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldUserID, vs...))
}
// ProviderTypeEQ applies the EQ predicate on the "provider_type" field.
func ProviderTypeEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderType, v))
}
// ProviderTypeNEQ applies the NEQ predicate on the "provider_type" field.
func ProviderTypeNEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldProviderType, v))
}
// ProviderTypeIn applies the In predicate on the "provider_type" field.
func ProviderTypeIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldProviderType, vs...))
}
// ProviderTypeNotIn applies the NotIn predicate on the "provider_type" field.
func ProviderTypeNotIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldProviderType, vs...))
}
// ProviderTypeGT applies the GT predicate on the "provider_type" field.
func ProviderTypeGT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldProviderType, v))
}
// ProviderTypeGTE applies the GTE predicate on the "provider_type" field.
func ProviderTypeGTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldProviderType, v))
}
// ProviderTypeLT applies the LT predicate on the "provider_type" field.
func ProviderTypeLT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldProviderType, v))
}
// ProviderTypeLTE applies the LTE predicate on the "provider_type" field.
func ProviderTypeLTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldProviderType, v))
}
// ProviderTypeContains applies the Contains predicate on the "provider_type" field.
func ProviderTypeContains(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContains(FieldProviderType, v))
}
// ProviderTypeHasPrefix applies the HasPrefix predicate on the "provider_type" field.
func ProviderTypeHasPrefix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasPrefix(FieldProviderType, v))
}
// ProviderTypeHasSuffix applies the HasSuffix predicate on the "provider_type" field.
func ProviderTypeHasSuffix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasSuffix(FieldProviderType, v))
}
// ProviderTypeEqualFold applies the EqualFold predicate on the "provider_type" field.
func ProviderTypeEqualFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEqualFold(FieldProviderType, v))
}
// ProviderTypeContainsFold applies the ContainsFold predicate on the "provider_type" field.
func ProviderTypeContainsFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContainsFold(FieldProviderType, v))
}
// ProviderKeyEQ applies the EQ predicate on the "provider_key" field.
func ProviderKeyEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderKey, v))
}
// ProviderKeyNEQ applies the NEQ predicate on the "provider_key" field.
func ProviderKeyNEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldProviderKey, v))
}
// ProviderKeyIn applies the In predicate on the "provider_key" field.
func ProviderKeyIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldProviderKey, vs...))
}
// ProviderKeyNotIn applies the NotIn predicate on the "provider_key" field.
func ProviderKeyNotIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldProviderKey, vs...))
}
// ProviderKeyGT applies the GT predicate on the "provider_key" field.
func ProviderKeyGT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldProviderKey, v))
}
// ProviderKeyGTE applies the GTE predicate on the "provider_key" field.
func ProviderKeyGTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldProviderKey, v))
}
// ProviderKeyLT applies the LT predicate on the "provider_key" field.
func ProviderKeyLT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldProviderKey, v))
}
// ProviderKeyLTE applies the LTE predicate on the "provider_key" field.
func ProviderKeyLTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldProviderKey, v))
}
// ProviderKeyContains applies the Contains predicate on the "provider_key" field.
func ProviderKeyContains(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContains(FieldProviderKey, v))
}
// ProviderKeyHasPrefix applies the HasPrefix predicate on the "provider_key" field.
func ProviderKeyHasPrefix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasPrefix(FieldProviderKey, v))
}
// ProviderKeyHasSuffix applies the HasSuffix predicate on the "provider_key" field.
func ProviderKeyHasSuffix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasSuffix(FieldProviderKey, v))
}
// ProviderKeyEqualFold applies the EqualFold predicate on the "provider_key" field.
func ProviderKeyEqualFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEqualFold(FieldProviderKey, v))
}
// ProviderKeyContainsFold applies the ContainsFold predicate on the "provider_key" field.
func ProviderKeyContainsFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContainsFold(FieldProviderKey, v))
}
// ProviderSubjectEQ applies the EQ predicate on the "provider_subject" field.
func ProviderSubjectEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldProviderSubject, v))
}
// ProviderSubjectNEQ applies the NEQ predicate on the "provider_subject" field.
func ProviderSubjectNEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldProviderSubject, v))
}
// ProviderSubjectIn applies the In predicate on the "provider_subject" field.
func ProviderSubjectIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldProviderSubject, vs...))
}
// ProviderSubjectNotIn applies the NotIn predicate on the "provider_subject" field.
func ProviderSubjectNotIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldProviderSubject, vs...))
}
// ProviderSubjectGT applies the GT predicate on the "provider_subject" field.
func ProviderSubjectGT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldProviderSubject, v))
}
// ProviderSubjectGTE applies the GTE predicate on the "provider_subject" field.
func ProviderSubjectGTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldProviderSubject, v))
}
// ProviderSubjectLT applies the LT predicate on the "provider_subject" field.
func ProviderSubjectLT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldProviderSubject, v))
}
// ProviderSubjectLTE applies the LTE predicate on the "provider_subject" field.
func ProviderSubjectLTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldProviderSubject, v))
}
// ProviderSubjectContains applies the Contains predicate on the "provider_subject" field.
func ProviderSubjectContains(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContains(FieldProviderSubject, v))
}
// ProviderSubjectHasPrefix applies the HasPrefix predicate on the "provider_subject" field.
func ProviderSubjectHasPrefix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasPrefix(FieldProviderSubject, v))
}
// ProviderSubjectHasSuffix applies the HasSuffix predicate on the "provider_subject" field.
func ProviderSubjectHasSuffix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasSuffix(FieldProviderSubject, v))
}
// ProviderSubjectEqualFold applies the EqualFold predicate on the "provider_subject" field.
func ProviderSubjectEqualFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEqualFold(FieldProviderSubject, v))
}
// ProviderSubjectContainsFold applies the ContainsFold predicate on the "provider_subject" field.
func ProviderSubjectContainsFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContainsFold(FieldProviderSubject, v))
}
// VerifiedAtEQ applies the EQ predicate on the "verified_at" field.
func VerifiedAtEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldVerifiedAt, v))
}
// VerifiedAtNEQ applies the NEQ predicate on the "verified_at" field.
func VerifiedAtNEQ(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldVerifiedAt, v))
}
// VerifiedAtIn applies the In predicate on the "verified_at" field.
func VerifiedAtIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldVerifiedAt, vs...))
}
// VerifiedAtNotIn applies the NotIn predicate on the "verified_at" field.
func VerifiedAtNotIn(vs ...time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldVerifiedAt, vs...))
}
// VerifiedAtGT applies the GT predicate on the "verified_at" field.
func VerifiedAtGT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldVerifiedAt, v))
}
// VerifiedAtGTE applies the GTE predicate on the "verified_at" field.
func VerifiedAtGTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldVerifiedAt, v))
}
// VerifiedAtLT applies the LT predicate on the "verified_at" field.
func VerifiedAtLT(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldVerifiedAt, v))
}
// VerifiedAtLTE applies the LTE predicate on the "verified_at" field.
func VerifiedAtLTE(v time.Time) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldVerifiedAt, v))
}
// VerifiedAtIsNil applies the IsNil predicate on the "verified_at" field.
func VerifiedAtIsNil() predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIsNull(FieldVerifiedAt))
}
// VerifiedAtNotNil applies the NotNil predicate on the "verified_at" field.
func VerifiedAtNotNil() predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotNull(FieldVerifiedAt))
}
// IssuerEQ applies the EQ predicate on the "issuer" field.
func IssuerEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEQ(FieldIssuer, v))
}
// IssuerNEQ applies the NEQ predicate on the "issuer" field.
func IssuerNEQ(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNEQ(FieldIssuer, v))
}
// IssuerIn applies the In predicate on the "issuer" field.
func IssuerIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIn(FieldIssuer, vs...))
}
// IssuerNotIn applies the NotIn predicate on the "issuer" field.
func IssuerNotIn(vs ...string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotIn(FieldIssuer, vs...))
}
// IssuerGT applies the GT predicate on the "issuer" field.
func IssuerGT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGT(FieldIssuer, v))
}
// IssuerGTE applies the GTE predicate on the "issuer" field.
func IssuerGTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldGTE(FieldIssuer, v))
}
// IssuerLT applies the LT predicate on the "issuer" field.
func IssuerLT(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLT(FieldIssuer, v))
}
// IssuerLTE applies the LTE predicate on the "issuer" field.
func IssuerLTE(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldLTE(FieldIssuer, v))
}
// IssuerContains applies the Contains predicate on the "issuer" field.
func IssuerContains(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContains(FieldIssuer, v))
}
// IssuerHasPrefix applies the HasPrefix predicate on the "issuer" field.
func IssuerHasPrefix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasPrefix(FieldIssuer, v))
}
// IssuerHasSuffix applies the HasSuffix predicate on the "issuer" field.
func IssuerHasSuffix(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldHasSuffix(FieldIssuer, v))
}
// IssuerIsNil applies the IsNil predicate on the "issuer" field.
func IssuerIsNil() predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldIsNull(FieldIssuer))
}
// IssuerNotNil applies the NotNil predicate on the "issuer" field.
func IssuerNotNil() predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldNotNull(FieldIssuer))
}
// IssuerEqualFold applies the EqualFold predicate on the "issuer" field.
func IssuerEqualFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldEqualFold(FieldIssuer, v))
}
// IssuerContainsFold applies the ContainsFold predicate on the "issuer" field.
func IssuerContainsFold(v string) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.FieldContainsFold(FieldIssuer, v))
}
// HasUser applies the HasEdge predicate on the "user" edge.
func HasUser() predicate.AuthIdentity {
return predicate.AuthIdentity(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.AuthIdentity {
return predicate.AuthIdentity(func(s *sql.Selector) {
step := newUserStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasChannels applies the HasEdge predicate on the "channels" edge.
func HasChannels() predicate.AuthIdentity {
return predicate.AuthIdentity(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, ChannelsTable, ChannelsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasChannelsWith applies the HasEdge predicate on the "channels" edge with a given conditions (other predicates).
func HasChannelsWith(preds ...predicate.AuthIdentityChannel) predicate.AuthIdentity {
return predicate.AuthIdentity(func(s *sql.Selector) {
step := newChannelsStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasAdoptionDecisions applies the HasEdge predicate on the "adoption_decisions" edge.
func HasAdoptionDecisions() predicate.AuthIdentity {
return predicate.AuthIdentity(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, AdoptionDecisionsTable, AdoptionDecisionsColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasAdoptionDecisionsWith applies the HasEdge predicate on the "adoption_decisions" edge with a given conditions (other predicates).
func HasAdoptionDecisionsWith(preds ...predicate.IdentityAdoptionDecision) predicate.AuthIdentity {
return predicate.AuthIdentity(func(s *sql.Selector) {
step := newAdoptionDecisionsStep()
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.AuthIdentity) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.AuthIdentity) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.AuthIdentity) predicate.AuthIdentity {
return predicate.AuthIdentity(sql.NotPredicates(p))
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/user"
)
// AuthIdentityCreate is the builder for creating a AuthIdentity entity.
type AuthIdentityCreate struct {
config
mutation *AuthIdentityMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (_c *AuthIdentityCreate) SetCreatedAt(v time.Time) *AuthIdentityCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *AuthIdentityCreate) SetNillableCreatedAt(v *time.Time) *AuthIdentityCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *AuthIdentityCreate) SetUpdatedAt(v time.Time) *AuthIdentityCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *AuthIdentityCreate) SetNillableUpdatedAt(v *time.Time) *AuthIdentityCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetUserID sets the "user_id" field.
func (_c *AuthIdentityCreate) SetUserID(v int64) *AuthIdentityCreate {
_c.mutation.SetUserID(v)
return _c
}
// SetProviderType sets the "provider_type" field.
func (_c *AuthIdentityCreate) SetProviderType(v string) *AuthIdentityCreate {
_c.mutation.SetProviderType(v)
return _c
}
// SetProviderKey sets the "provider_key" field.
func (_c *AuthIdentityCreate) SetProviderKey(v string) *AuthIdentityCreate {
_c.mutation.SetProviderKey(v)
return _c
}
// SetProviderSubject sets the "provider_subject" field.
func (_c *AuthIdentityCreate) SetProviderSubject(v string) *AuthIdentityCreate {
_c.mutation.SetProviderSubject(v)
return _c
}
// SetVerifiedAt sets the "verified_at" field.
func (_c *AuthIdentityCreate) SetVerifiedAt(v time.Time) *AuthIdentityCreate {
_c.mutation.SetVerifiedAt(v)
return _c
}
// SetNillableVerifiedAt sets the "verified_at" field if the given value is not nil.
func (_c *AuthIdentityCreate) SetNillableVerifiedAt(v *time.Time) *AuthIdentityCreate {
if v != nil {
_c.SetVerifiedAt(*v)
}
return _c
}
// SetIssuer sets the "issuer" field.
func (_c *AuthIdentityCreate) SetIssuer(v string) *AuthIdentityCreate {
_c.mutation.SetIssuer(v)
return _c
}
// SetNillableIssuer sets the "issuer" field if the given value is not nil.
func (_c *AuthIdentityCreate) SetNillableIssuer(v *string) *AuthIdentityCreate {
if v != nil {
_c.SetIssuer(*v)
}
return _c
}
// SetMetadata sets the "metadata" field.
func (_c *AuthIdentityCreate) SetMetadata(v map[string]interface{}) *AuthIdentityCreate {
_c.mutation.SetMetadata(v)
return _c
}
// SetUser sets the "user" edge to the User entity.
func (_c *AuthIdentityCreate) SetUser(v *User) *AuthIdentityCreate {
return _c.SetUserID(v.ID)
}
// AddChannelIDs adds the "channels" edge to the AuthIdentityChannel entity by IDs.
func (_c *AuthIdentityCreate) AddChannelIDs(ids ...int64) *AuthIdentityCreate {
_c.mutation.AddChannelIDs(ids...)
return _c
}
// AddChannels adds the "channels" edges to the AuthIdentityChannel entity.
func (_c *AuthIdentityCreate) AddChannels(v ...*AuthIdentityChannel) *AuthIdentityCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddChannelIDs(ids...)
}
// AddAdoptionDecisionIDs adds the "adoption_decisions" edge to the IdentityAdoptionDecision entity by IDs.
func (_c *AuthIdentityCreate) AddAdoptionDecisionIDs(ids ...int64) *AuthIdentityCreate {
_c.mutation.AddAdoptionDecisionIDs(ids...)
return _c
}
// AddAdoptionDecisions adds the "adoption_decisions" edges to the IdentityAdoptionDecision entity.
func (_c *AuthIdentityCreate) AddAdoptionDecisions(v ...*IdentityAdoptionDecision) *AuthIdentityCreate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _c.AddAdoptionDecisionIDs(ids...)
}
// Mutation returns the AuthIdentityMutation object of the builder.
func (_c *AuthIdentityCreate) Mutation() *AuthIdentityMutation {
return _c.mutation
}
// Save creates the AuthIdentity in the database.
func (_c *AuthIdentityCreate) Save(ctx context.Context) (*AuthIdentity, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *AuthIdentityCreate) SaveX(ctx context.Context) *AuthIdentity {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AuthIdentityCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AuthIdentityCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *AuthIdentityCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := authidentity.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := authidentity.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.Metadata(); !ok {
v := authidentity.DefaultMetadata()
_c.mutation.SetMetadata(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *AuthIdentityCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AuthIdentity.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AuthIdentity.updated_at"`)}
}
if _, ok := _c.mutation.UserID(); !ok {
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "AuthIdentity.user_id"`)}
}
if _, ok := _c.mutation.ProviderType(); !ok {
return &ValidationError{Name: "provider_type", err: errors.New(`ent: missing required field "AuthIdentity.provider_type"`)}
}
if v, ok := _c.mutation.ProviderType(); ok {
if err := authidentity.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_type": %w`, err)}
}
}
if _, ok := _c.mutation.ProviderKey(); !ok {
return &ValidationError{Name: "provider_key", err: errors.New(`ent: missing required field "AuthIdentity.provider_key"`)}
}
if v, ok := _c.mutation.ProviderKey(); ok {
if err := authidentity.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_key": %w`, err)}
}
}
if _, ok := _c.mutation.ProviderSubject(); !ok {
return &ValidationError{Name: "provider_subject", err: errors.New(`ent: missing required field "AuthIdentity.provider_subject"`)}
}
if v, ok := _c.mutation.ProviderSubject(); ok {
if err := authidentity.ProviderSubjectValidator(v); err != nil {
return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_subject": %w`, err)}
}
}
if _, ok := _c.mutation.Metadata(); !ok {
return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "AuthIdentity.metadata"`)}
}
if len(_c.mutation.UserIDs()) == 0 {
return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "AuthIdentity.user"`)}
}
return nil
}
func (_c *AuthIdentityCreate) sqlSave(ctx context.Context) (*AuthIdentity, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *AuthIdentityCreate) createSpec() (*AuthIdentity, *sqlgraph.CreateSpec) {
var (
_node = &AuthIdentity{config: _c.config}
_spec = sqlgraph.NewCreateSpec(authidentity.Table, sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(authidentity.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(authidentity.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.ProviderType(); ok {
_spec.SetField(authidentity.FieldProviderType, field.TypeString, value)
_node.ProviderType = value
}
if value, ok := _c.mutation.ProviderKey(); ok {
_spec.SetField(authidentity.FieldProviderKey, field.TypeString, value)
_node.ProviderKey = value
}
if value, ok := _c.mutation.ProviderSubject(); ok {
_spec.SetField(authidentity.FieldProviderSubject, field.TypeString, value)
_node.ProviderSubject = value
}
if value, ok := _c.mutation.VerifiedAt(); ok {
_spec.SetField(authidentity.FieldVerifiedAt, field.TypeTime, value)
_node.VerifiedAt = &value
}
if value, ok := _c.mutation.Issuer(); ok {
_spec.SetField(authidentity.FieldIssuer, field.TypeString, value)
_node.Issuer = &value
}
if value, ok := _c.mutation.Metadata(); ok {
_spec.SetField(authidentity.FieldMetadata, field.TypeJSON, value)
_node.Metadata = value
}
if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentity.UserTable,
Columns: []string{authidentity.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.UserID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.ChannelsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
if nodes := _c.mutation.AdoptionDecisionsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AuthIdentity.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AuthIdentityUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AuthIdentityCreate) OnConflict(opts ...sql.ConflictOption) *AuthIdentityUpsertOne {
_c.conflict = opts
return &AuthIdentityUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AuthIdentityCreate) OnConflictColumns(columns ...string) *AuthIdentityUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AuthIdentityUpsertOne{
create: _c,
}
}
type (
// AuthIdentityUpsertOne is the builder for "upsert"-ing
// one AuthIdentity node.
AuthIdentityUpsertOne struct {
create *AuthIdentityCreate
}
// AuthIdentityUpsert is the "OnConflict" setter.
AuthIdentityUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityUpsert) SetUpdatedAt(v time.Time) *AuthIdentityUpsert {
u.Set(authidentity.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateUpdatedAt() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldUpdatedAt)
return u
}
// SetUserID sets the "user_id" field.
func (u *AuthIdentityUpsert) SetUserID(v int64) *AuthIdentityUpsert {
u.Set(authidentity.FieldUserID, v)
return u
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateUserID() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldUserID)
return u
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityUpsert) SetProviderType(v string) *AuthIdentityUpsert {
u.Set(authidentity.FieldProviderType, v)
return u
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateProviderType() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldProviderType)
return u
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityUpsert) SetProviderKey(v string) *AuthIdentityUpsert {
u.Set(authidentity.FieldProviderKey, v)
return u
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateProviderKey() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldProviderKey)
return u
}
// SetProviderSubject sets the "provider_subject" field.
func (u *AuthIdentityUpsert) SetProviderSubject(v string) *AuthIdentityUpsert {
u.Set(authidentity.FieldProviderSubject, v)
return u
}
// UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateProviderSubject() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldProviderSubject)
return u
}
// SetVerifiedAt sets the "verified_at" field.
func (u *AuthIdentityUpsert) SetVerifiedAt(v time.Time) *AuthIdentityUpsert {
u.Set(authidentity.FieldVerifiedAt, v)
return u
}
// UpdateVerifiedAt sets the "verified_at" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateVerifiedAt() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldVerifiedAt)
return u
}
// ClearVerifiedAt clears the value of the "verified_at" field.
func (u *AuthIdentityUpsert) ClearVerifiedAt() *AuthIdentityUpsert {
u.SetNull(authidentity.FieldVerifiedAt)
return u
}
// SetIssuer sets the "issuer" field.
func (u *AuthIdentityUpsert) SetIssuer(v string) *AuthIdentityUpsert {
u.Set(authidentity.FieldIssuer, v)
return u
}
// UpdateIssuer sets the "issuer" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateIssuer() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldIssuer)
return u
}
// ClearIssuer clears the value of the "issuer" field.
func (u *AuthIdentityUpsert) ClearIssuer() *AuthIdentityUpsert {
u.SetNull(authidentity.FieldIssuer)
return u
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityUpsert) SetMetadata(v map[string]interface{}) *AuthIdentityUpsert {
u.Set(authidentity.FieldMetadata, v)
return u
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityUpsert) UpdateMetadata() *AuthIdentityUpsert {
u.SetExcluded(authidentity.FieldMetadata)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AuthIdentityUpsertOne) UpdateNewValues() *AuthIdentityUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(authidentity.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AuthIdentityUpsertOne) Ignore() *AuthIdentityUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AuthIdentityUpsertOne) DoNothing() *AuthIdentityUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AuthIdentityCreate.OnConflict
// documentation for more info.
func (u *AuthIdentityUpsertOne) Update(set func(*AuthIdentityUpsert)) *AuthIdentityUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AuthIdentityUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityUpsertOne) SetUpdatedAt(v time.Time) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateUpdatedAt() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateUpdatedAt()
})
}
// SetUserID sets the "user_id" field.
func (u *AuthIdentityUpsertOne) SetUserID(v int64) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateUserID() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateUserID()
})
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityUpsertOne) SetProviderType(v string) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderType(v)
})
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateProviderType() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderType()
})
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityUpsertOne) SetProviderKey(v string) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderKey(v)
})
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateProviderKey() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderKey()
})
}
// SetProviderSubject sets the "provider_subject" field.
func (u *AuthIdentityUpsertOne) SetProviderSubject(v string) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderSubject(v)
})
}
// UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateProviderSubject() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderSubject()
})
}
// SetVerifiedAt sets the "verified_at" field.
func (u *AuthIdentityUpsertOne) SetVerifiedAt(v time.Time) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetVerifiedAt(v)
})
}
// UpdateVerifiedAt sets the "verified_at" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateVerifiedAt() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateVerifiedAt()
})
}
// ClearVerifiedAt clears the value of the "verified_at" field.
func (u *AuthIdentityUpsertOne) ClearVerifiedAt() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.ClearVerifiedAt()
})
}
// SetIssuer sets the "issuer" field.
func (u *AuthIdentityUpsertOne) SetIssuer(v string) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetIssuer(v)
})
}
// UpdateIssuer sets the "issuer" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateIssuer() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateIssuer()
})
}
// ClearIssuer clears the value of the "issuer" field.
func (u *AuthIdentityUpsertOne) ClearIssuer() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.ClearIssuer()
})
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityUpsertOne) SetMetadata(v map[string]interface{}) *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetMetadata(v)
})
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityUpsertOne) UpdateMetadata() *AuthIdentityUpsertOne {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateMetadata()
})
}
// Exec executes the query.
func (u *AuthIdentityUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AuthIdentityCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AuthIdentityUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *AuthIdentityUpsertOne) ID(ctx context.Context) (id int64, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *AuthIdentityUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// AuthIdentityCreateBulk is the builder for creating many AuthIdentity entities in bulk.
type AuthIdentityCreateBulk struct {
config
err error
builders []*AuthIdentityCreate
conflict []sql.ConflictOption
}
// Save creates the AuthIdentity entities in the database.
func (_c *AuthIdentityCreateBulk) Save(ctx context.Context) ([]*AuthIdentity, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*AuthIdentity, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthIdentityMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *AuthIdentityCreateBulk) SaveX(ctx context.Context) []*AuthIdentity {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AuthIdentityCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AuthIdentityCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AuthIdentity.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AuthIdentityUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AuthIdentityCreateBulk) OnConflict(opts ...sql.ConflictOption) *AuthIdentityUpsertBulk {
_c.conflict = opts
return &AuthIdentityUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AuthIdentityCreateBulk) OnConflictColumns(columns ...string) *AuthIdentityUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AuthIdentityUpsertBulk{
create: _c,
}
}
// AuthIdentityUpsertBulk is the builder for "upsert"-ing
// a bulk of AuthIdentity nodes.
type AuthIdentityUpsertBulk struct {
create *AuthIdentityCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AuthIdentityUpsertBulk) UpdateNewValues() *AuthIdentityUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(authidentity.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AuthIdentity.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AuthIdentityUpsertBulk) Ignore() *AuthIdentityUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AuthIdentityUpsertBulk) DoNothing() *AuthIdentityUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AuthIdentityCreateBulk.OnConflict
// documentation for more info.
func (u *AuthIdentityUpsertBulk) Update(set func(*AuthIdentityUpsert)) *AuthIdentityUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AuthIdentityUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityUpsertBulk) SetUpdatedAt(v time.Time) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateUpdatedAt() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateUpdatedAt()
})
}
// SetUserID sets the "user_id" field.
func (u *AuthIdentityUpsertBulk) SetUserID(v int64) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetUserID(v)
})
}
// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateUserID() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateUserID()
})
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityUpsertBulk) SetProviderType(v string) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderType(v)
})
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateProviderType() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderType()
})
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityUpsertBulk) SetProviderKey(v string) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderKey(v)
})
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateProviderKey() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderKey()
})
}
// SetProviderSubject sets the "provider_subject" field.
func (u *AuthIdentityUpsertBulk) SetProviderSubject(v string) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetProviderSubject(v)
})
}
// UpdateProviderSubject sets the "provider_subject" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateProviderSubject() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateProviderSubject()
})
}
// SetVerifiedAt sets the "verified_at" field.
func (u *AuthIdentityUpsertBulk) SetVerifiedAt(v time.Time) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetVerifiedAt(v)
})
}
// UpdateVerifiedAt sets the "verified_at" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateVerifiedAt() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateVerifiedAt()
})
}
// ClearVerifiedAt clears the value of the "verified_at" field.
func (u *AuthIdentityUpsertBulk) ClearVerifiedAt() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.ClearVerifiedAt()
})
}
// SetIssuer sets the "issuer" field.
func (u *AuthIdentityUpsertBulk) SetIssuer(v string) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetIssuer(v)
})
}
// UpdateIssuer sets the "issuer" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateIssuer() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateIssuer()
})
}
// ClearIssuer clears the value of the "issuer" field.
func (u *AuthIdentityUpsertBulk) ClearIssuer() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.ClearIssuer()
})
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityUpsertBulk) SetMetadata(v map[string]interface{}) *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.SetMetadata(v)
})
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityUpsertBulk) UpdateMetadata() *AuthIdentityUpsertBulk {
return u.Update(func(s *AuthIdentityUpsert) {
s.UpdateMetadata()
})
}
// Exec executes the query.
func (u *AuthIdentityUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AuthIdentityCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AuthIdentityCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AuthIdentityUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AuthIdentityDelete is the builder for deleting a AuthIdentity entity.
type AuthIdentityDelete struct {
config
hooks []Hook
mutation *AuthIdentityMutation
}
// Where appends a list predicates to the AuthIdentityDelete builder.
func (_d *AuthIdentityDelete) Where(ps ...predicate.AuthIdentity) *AuthIdentityDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *AuthIdentityDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AuthIdentityDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *AuthIdentityDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(authidentity.Table, sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// AuthIdentityDeleteOne is the builder for deleting a single AuthIdentity entity.
type AuthIdentityDeleteOne struct {
_d *AuthIdentityDelete
}
// Where appends a list predicates to the AuthIdentityDelete builder.
func (_d *AuthIdentityDeleteOne) Where(ps ...predicate.AuthIdentity) *AuthIdentityDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *AuthIdentityDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{authidentity.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AuthIdentityDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/user"
)
// AuthIdentityQuery is the builder for querying AuthIdentity entities.
type AuthIdentityQuery struct {
config
ctx *QueryContext
order []authidentity.OrderOption
inters []Interceptor
predicates []predicate.AuthIdentity
withUser *UserQuery
withChannels *AuthIdentityChannelQuery
withAdoptionDecisions *IdentityAdoptionDecisionQuery
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the AuthIdentityQuery builder.
func (_q *AuthIdentityQuery) Where(ps ...predicate.AuthIdentity) *AuthIdentityQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *AuthIdentityQuery) Limit(limit int) *AuthIdentityQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *AuthIdentityQuery) Offset(offset int) *AuthIdentityQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *AuthIdentityQuery) Unique(unique bool) *AuthIdentityQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *AuthIdentityQuery) Order(o ...authidentity.OrderOption) *AuthIdentityQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryUser chains the current query on the "user" edge.
func (_q *AuthIdentityQuery) QueryUser() *UserQuery {
query := (&UserClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, selector),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, authidentity.UserTable, authidentity.UserColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryChannels chains the current query on the "channels" edge.
func (_q *AuthIdentityQuery) QueryChannels() *AuthIdentityChannelQuery {
query := (&AuthIdentityChannelClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, selector),
sqlgraph.To(authidentitychannel.Table, authidentitychannel.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, authidentity.ChannelsTable, authidentity.ChannelsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// QueryAdoptionDecisions chains the current query on the "adoption_decisions" edge.
func (_q *AuthIdentityQuery) QueryAdoptionDecisions() *IdentityAdoptionDecisionQuery {
query := (&IdentityAdoptionDecisionClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, selector),
sqlgraph.To(identityadoptiondecision.Table, identityadoptiondecision.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, authidentity.AdoptionDecisionsTable, authidentity.AdoptionDecisionsColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first AuthIdentity entity from the query.
// Returns a *NotFoundError when no AuthIdentity was found.
func (_q *AuthIdentityQuery) First(ctx context.Context) (*AuthIdentity, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{authidentity.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *AuthIdentityQuery) FirstX(ctx context.Context) *AuthIdentity {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first AuthIdentity ID from the query.
// Returns a *NotFoundError when no AuthIdentity ID was found.
func (_q *AuthIdentityQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{authidentity.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *AuthIdentityQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single AuthIdentity entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one AuthIdentity entity is found.
// Returns a *NotFoundError when no AuthIdentity entities are found.
func (_q *AuthIdentityQuery) Only(ctx context.Context) (*AuthIdentity, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{authidentity.Label}
default:
return nil, &NotSingularError{authidentity.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *AuthIdentityQuery) OnlyX(ctx context.Context) *AuthIdentity {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only AuthIdentity ID in the query.
// Returns a *NotSingularError when more than one AuthIdentity ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *AuthIdentityQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{authidentity.Label}
default:
err = &NotSingularError{authidentity.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *AuthIdentityQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of AuthIdentities.
func (_q *AuthIdentityQuery) All(ctx context.Context) ([]*AuthIdentity, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*AuthIdentity, *AuthIdentityQuery]()
return withInterceptors[[]*AuthIdentity](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *AuthIdentityQuery) AllX(ctx context.Context) []*AuthIdentity {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of AuthIdentity IDs.
func (_q *AuthIdentityQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(authidentity.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *AuthIdentityQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *AuthIdentityQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*AuthIdentityQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *AuthIdentityQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *AuthIdentityQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *AuthIdentityQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the AuthIdentityQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *AuthIdentityQuery) Clone() *AuthIdentityQuery {
if _q == nil {
return nil
}
return &AuthIdentityQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]authidentity.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.AuthIdentity{}, _q.predicates...),
withUser: _q.withUser.Clone(),
withChannels: _q.withChannels.Clone(),
withAdoptionDecisions: _q.withAdoptionDecisions.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithUser tells the query-builder to eager-load the nodes that are connected to
// the "user" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AuthIdentityQuery) WithUser(opts ...func(*UserQuery)) *AuthIdentityQuery {
query := (&UserClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withUser = query
return _q
}
// WithChannels tells the query-builder to eager-load the nodes that are connected to
// the "channels" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AuthIdentityQuery) WithChannels(opts ...func(*AuthIdentityChannelQuery)) *AuthIdentityQuery {
query := (&AuthIdentityChannelClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withChannels = query
return _q
}
// WithAdoptionDecisions tells the query-builder to eager-load the nodes that are connected to
// the "adoption_decisions" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AuthIdentityQuery) WithAdoptionDecisions(opts ...func(*IdentityAdoptionDecisionQuery)) *AuthIdentityQuery {
query := (&IdentityAdoptionDecisionClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withAdoptionDecisions = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.AuthIdentity.Query().
// GroupBy(authidentity.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *AuthIdentityQuery) GroupBy(field string, fields ...string) *AuthIdentityGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &AuthIdentityGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = authidentity.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.AuthIdentity.Query().
// Select(authidentity.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *AuthIdentityQuery) Select(fields ...string) *AuthIdentitySelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &AuthIdentitySelect{AuthIdentityQuery: _q}
sbuild.label = authidentity.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AuthIdentitySelect configured with the given aggregations.
func (_q *AuthIdentityQuery) Aggregate(fns ...AggregateFunc) *AuthIdentitySelect {
return _q.Select().Aggregate(fns...)
}
func (_q *AuthIdentityQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !authidentity.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *AuthIdentityQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthIdentity, error) {
var (
nodes = []*AuthIdentity{}
_spec = _q.querySpec()
loadedTypes = [3]bool{
_q.withUser != nil,
_q.withChannels != nil,
_q.withAdoptionDecisions != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*AuthIdentity).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &AuthIdentity{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withUser; query != nil {
if err := _q.loadUser(ctx, query, nodes, nil,
func(n *AuthIdentity, e *User) { n.Edges.User = e }); err != nil {
return nil, err
}
}
if query := _q.withChannels; query != nil {
if err := _q.loadChannels(ctx, query, nodes,
func(n *AuthIdentity) { n.Edges.Channels = []*AuthIdentityChannel{} },
func(n *AuthIdentity, e *AuthIdentityChannel) { n.Edges.Channels = append(n.Edges.Channels, e) }); err != nil {
return nil, err
}
}
if query := _q.withAdoptionDecisions; query != nil {
if err := _q.loadAdoptionDecisions(ctx, query, nodes,
func(n *AuthIdentity) { n.Edges.AdoptionDecisions = []*IdentityAdoptionDecision{} },
func(n *AuthIdentity, e *IdentityAdoptionDecision) {
n.Edges.AdoptionDecisions = append(n.Edges.AdoptionDecisions, e)
}); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *AuthIdentityQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*AuthIdentity, init func(*AuthIdentity), assign func(*AuthIdentity, *User)) error {
ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*AuthIdentity)
for i := range nodes {
fk := nodes[i].UserID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(user.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "user_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *AuthIdentityQuery) loadChannels(ctx context.Context, query *AuthIdentityChannelQuery, nodes []*AuthIdentity, init func(*AuthIdentity), assign func(*AuthIdentity, *AuthIdentityChannel)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*AuthIdentity)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(authidentitychannel.FieldIdentityID)
}
query.Where(predicate.AuthIdentityChannel(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(authidentity.ChannelsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.IdentityID
node, ok := nodeids[fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "identity_id" returned %v for node %v`, fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *AuthIdentityQuery) loadAdoptionDecisions(ctx context.Context, query *IdentityAdoptionDecisionQuery, nodes []*AuthIdentity, init func(*AuthIdentity), assign func(*AuthIdentity, *IdentityAdoptionDecision)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int64]*AuthIdentity)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
if len(query.ctx.Fields) > 0 {
query.ctx.AppendFieldOnce(identityadoptiondecision.FieldIdentityID)
}
query.Where(predicate.IdentityAdoptionDecision(func(s *sql.Selector) {
s.Where(sql.InValues(s.C(authidentity.AdoptionDecisionsColumn), fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.IdentityID
if fk == nil {
return fmt.Errorf(`foreign-key "identity_id" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected referenced foreign-key "identity_id" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (_q *AuthIdentityQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *AuthIdentityQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(authidentity.Table, authidentity.Columns, sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authidentity.FieldID)
for i := range fields {
if fields[i] != authidentity.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if _q.withUser != nil {
_spec.Node.AddColumnOnce(authidentity.FieldUserID)
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *AuthIdentityQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(authidentity.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = authidentity.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *AuthIdentityQuery) ForUpdate(opts ...sql.LockOption) *AuthIdentityQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *AuthIdentityQuery) ForShare(opts ...sql.LockOption) *AuthIdentityQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// AuthIdentityGroupBy is the group-by builder for AuthIdentity entities.
type AuthIdentityGroupBy struct {
selector
build *AuthIdentityQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *AuthIdentityGroupBy) Aggregate(fns ...AggregateFunc) *AuthIdentityGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *AuthIdentityGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AuthIdentityQuery, *AuthIdentityGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *AuthIdentityGroupBy) sqlScan(ctx context.Context, root *AuthIdentityQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AuthIdentitySelect is the builder for selecting fields of AuthIdentity entities.
type AuthIdentitySelect struct {
*AuthIdentityQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *AuthIdentitySelect) Aggregate(fns ...AggregateFunc) *AuthIdentitySelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *AuthIdentitySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AuthIdentityQuery, *AuthIdentitySelect](ctx, _s.AuthIdentityQuery, _s, _s.inters, v)
}
func (_s *AuthIdentitySelect) sqlScan(ctx context.Context, root *AuthIdentityQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/predicate"
"github.com/Wei-Shaw/sub2api/ent/user"
)
// AuthIdentityUpdate is the builder for updating AuthIdentity entities.
type AuthIdentityUpdate struct {
config
hooks []Hook
mutation *AuthIdentityMutation
}
// Where appends a list predicates to the AuthIdentityUpdate builder.
func (_u *AuthIdentityUpdate) Where(ps ...predicate.AuthIdentity) *AuthIdentityUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AuthIdentityUpdate) SetUpdatedAt(v time.Time) *AuthIdentityUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *AuthIdentityUpdate) SetUserID(v int64) *AuthIdentityUpdate {
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableUserID(v *int64) *AuthIdentityUpdate {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// SetProviderType sets the "provider_type" field.
func (_u *AuthIdentityUpdate) SetProviderType(v string) *AuthIdentityUpdate {
_u.mutation.SetProviderType(v)
return _u
}
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableProviderType(v *string) *AuthIdentityUpdate {
if v != nil {
_u.SetProviderType(*v)
}
return _u
}
// SetProviderKey sets the "provider_key" field.
func (_u *AuthIdentityUpdate) SetProviderKey(v string) *AuthIdentityUpdate {
_u.mutation.SetProviderKey(v)
return _u
}
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableProviderKey(v *string) *AuthIdentityUpdate {
if v != nil {
_u.SetProviderKey(*v)
}
return _u
}
// SetProviderSubject sets the "provider_subject" field.
func (_u *AuthIdentityUpdate) SetProviderSubject(v string) *AuthIdentityUpdate {
_u.mutation.SetProviderSubject(v)
return _u
}
// SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableProviderSubject(v *string) *AuthIdentityUpdate {
if v != nil {
_u.SetProviderSubject(*v)
}
return _u
}
// SetVerifiedAt sets the "verified_at" field.
func (_u *AuthIdentityUpdate) SetVerifiedAt(v time.Time) *AuthIdentityUpdate {
_u.mutation.SetVerifiedAt(v)
return _u
}
// SetNillableVerifiedAt sets the "verified_at" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableVerifiedAt(v *time.Time) *AuthIdentityUpdate {
if v != nil {
_u.SetVerifiedAt(*v)
}
return _u
}
// ClearVerifiedAt clears the value of the "verified_at" field.
func (_u *AuthIdentityUpdate) ClearVerifiedAt() *AuthIdentityUpdate {
_u.mutation.ClearVerifiedAt()
return _u
}
// SetIssuer sets the "issuer" field.
func (_u *AuthIdentityUpdate) SetIssuer(v string) *AuthIdentityUpdate {
_u.mutation.SetIssuer(v)
return _u
}
// SetNillableIssuer sets the "issuer" field if the given value is not nil.
func (_u *AuthIdentityUpdate) SetNillableIssuer(v *string) *AuthIdentityUpdate {
if v != nil {
_u.SetIssuer(*v)
}
return _u
}
// ClearIssuer clears the value of the "issuer" field.
func (_u *AuthIdentityUpdate) ClearIssuer() *AuthIdentityUpdate {
_u.mutation.ClearIssuer()
return _u
}
// SetMetadata sets the "metadata" field.
func (_u *AuthIdentityUpdate) SetMetadata(v map[string]interface{}) *AuthIdentityUpdate {
_u.mutation.SetMetadata(v)
return _u
}
// SetUser sets the "user" edge to the User entity.
func (_u *AuthIdentityUpdate) SetUser(v *User) *AuthIdentityUpdate {
return _u.SetUserID(v.ID)
}
// AddChannelIDs adds the "channels" edge to the AuthIdentityChannel entity by IDs.
func (_u *AuthIdentityUpdate) AddChannelIDs(ids ...int64) *AuthIdentityUpdate {
_u.mutation.AddChannelIDs(ids...)
return _u
}
// AddChannels adds the "channels" edges to the AuthIdentityChannel entity.
func (_u *AuthIdentityUpdate) AddChannels(v ...*AuthIdentityChannel) *AuthIdentityUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddChannelIDs(ids...)
}
// AddAdoptionDecisionIDs adds the "adoption_decisions" edge to the IdentityAdoptionDecision entity by IDs.
func (_u *AuthIdentityUpdate) AddAdoptionDecisionIDs(ids ...int64) *AuthIdentityUpdate {
_u.mutation.AddAdoptionDecisionIDs(ids...)
return _u
}
// AddAdoptionDecisions adds the "adoption_decisions" edges to the IdentityAdoptionDecision entity.
func (_u *AuthIdentityUpdate) AddAdoptionDecisions(v ...*IdentityAdoptionDecision) *AuthIdentityUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddAdoptionDecisionIDs(ids...)
}
// Mutation returns the AuthIdentityMutation object of the builder.
func (_u *AuthIdentityUpdate) Mutation() *AuthIdentityMutation {
return _u.mutation
}
// ClearUser clears the "user" edge to the User entity.
func (_u *AuthIdentityUpdate) ClearUser() *AuthIdentityUpdate {
_u.mutation.ClearUser()
return _u
}
// ClearChannels clears all "channels" edges to the AuthIdentityChannel entity.
func (_u *AuthIdentityUpdate) ClearChannels() *AuthIdentityUpdate {
_u.mutation.ClearChannels()
return _u
}
// RemoveChannelIDs removes the "channels" edge to AuthIdentityChannel entities by IDs.
func (_u *AuthIdentityUpdate) RemoveChannelIDs(ids ...int64) *AuthIdentityUpdate {
_u.mutation.RemoveChannelIDs(ids...)
return _u
}
// RemoveChannels removes "channels" edges to AuthIdentityChannel entities.
func (_u *AuthIdentityUpdate) RemoveChannels(v ...*AuthIdentityChannel) *AuthIdentityUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveChannelIDs(ids...)
}
// ClearAdoptionDecisions clears all "adoption_decisions" edges to the IdentityAdoptionDecision entity.
func (_u *AuthIdentityUpdate) ClearAdoptionDecisions() *AuthIdentityUpdate {
_u.mutation.ClearAdoptionDecisions()
return _u
}
// RemoveAdoptionDecisionIDs removes the "adoption_decisions" edge to IdentityAdoptionDecision entities by IDs.
func (_u *AuthIdentityUpdate) RemoveAdoptionDecisionIDs(ids ...int64) *AuthIdentityUpdate {
_u.mutation.RemoveAdoptionDecisionIDs(ids...)
return _u
}
// RemoveAdoptionDecisions removes "adoption_decisions" edges to IdentityAdoptionDecision entities.
func (_u *AuthIdentityUpdate) RemoveAdoptionDecisions(v ...*IdentityAdoptionDecision) *AuthIdentityUpdate {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveAdoptionDecisionIDs(ids...)
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AuthIdentityUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthIdentityUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AuthIdentityUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthIdentityUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AuthIdentityUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := authidentity.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *AuthIdentityUpdate) check() error {
if v, ok := _u.mutation.ProviderType(); ok {
if err := authidentity.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_type": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderKey(); ok {
if err := authidentity.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_key": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderSubject(); ok {
if err := authidentity.ProviderSubjectValidator(v); err != nil {
return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_subject": %w`, err)}
}
}
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "AuthIdentity.user"`)
}
return nil
}
func (_u *AuthIdentityUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(authidentity.Table, authidentity.Columns, sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(authidentity.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.ProviderType(); ok {
_spec.SetField(authidentity.FieldProviderType, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderKey(); ok {
_spec.SetField(authidentity.FieldProviderKey, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderSubject(); ok {
_spec.SetField(authidentity.FieldProviderSubject, field.TypeString, value)
}
if value, ok := _u.mutation.VerifiedAt(); ok {
_spec.SetField(authidentity.FieldVerifiedAt, field.TypeTime, value)
}
if _u.mutation.VerifiedAtCleared() {
_spec.ClearField(authidentity.FieldVerifiedAt, field.TypeTime)
}
if value, ok := _u.mutation.Issuer(); ok {
_spec.SetField(authidentity.FieldIssuer, field.TypeString, value)
}
if _u.mutation.IssuerCleared() {
_spec.ClearField(authidentity.FieldIssuer, field.TypeString)
}
if value, ok := _u.mutation.Metadata(); ok {
_spec.SetField(authidentity.FieldMetadata, field.TypeJSON, value)
}
if _u.mutation.UserCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentity.UserTable,
Columns: []string{authidentity.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentity.UserTable,
Columns: []string{authidentity.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ChannelsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedChannelsIDs(); len(nodes) > 0 && !_u.mutation.ChannelsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ChannelsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.AdoptionDecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedAdoptionDecisionsIDs(); len(nodes) > 0 && !_u.mutation.AdoptionDecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.AdoptionDecisionsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authidentity.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AuthIdentityUpdateOne is the builder for updating a single AuthIdentity entity.
type AuthIdentityUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AuthIdentityMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AuthIdentityUpdateOne) SetUpdatedAt(v time.Time) *AuthIdentityUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetUserID sets the "user_id" field.
func (_u *AuthIdentityUpdateOne) SetUserID(v int64) *AuthIdentityUpdateOne {
_u.mutation.SetUserID(v)
return _u
}
// SetNillableUserID sets the "user_id" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableUserID(v *int64) *AuthIdentityUpdateOne {
if v != nil {
_u.SetUserID(*v)
}
return _u
}
// SetProviderType sets the "provider_type" field.
func (_u *AuthIdentityUpdateOne) SetProviderType(v string) *AuthIdentityUpdateOne {
_u.mutation.SetProviderType(v)
return _u
}
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableProviderType(v *string) *AuthIdentityUpdateOne {
if v != nil {
_u.SetProviderType(*v)
}
return _u
}
// SetProviderKey sets the "provider_key" field.
func (_u *AuthIdentityUpdateOne) SetProviderKey(v string) *AuthIdentityUpdateOne {
_u.mutation.SetProviderKey(v)
return _u
}
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableProviderKey(v *string) *AuthIdentityUpdateOne {
if v != nil {
_u.SetProviderKey(*v)
}
return _u
}
// SetProviderSubject sets the "provider_subject" field.
func (_u *AuthIdentityUpdateOne) SetProviderSubject(v string) *AuthIdentityUpdateOne {
_u.mutation.SetProviderSubject(v)
return _u
}
// SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableProviderSubject(v *string) *AuthIdentityUpdateOne {
if v != nil {
_u.SetProviderSubject(*v)
}
return _u
}
// SetVerifiedAt sets the "verified_at" field.
func (_u *AuthIdentityUpdateOne) SetVerifiedAt(v time.Time) *AuthIdentityUpdateOne {
_u.mutation.SetVerifiedAt(v)
return _u
}
// SetNillableVerifiedAt sets the "verified_at" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableVerifiedAt(v *time.Time) *AuthIdentityUpdateOne {
if v != nil {
_u.SetVerifiedAt(*v)
}
return _u
}
// ClearVerifiedAt clears the value of the "verified_at" field.
func (_u *AuthIdentityUpdateOne) ClearVerifiedAt() *AuthIdentityUpdateOne {
_u.mutation.ClearVerifiedAt()
return _u
}
// SetIssuer sets the "issuer" field.
func (_u *AuthIdentityUpdateOne) SetIssuer(v string) *AuthIdentityUpdateOne {
_u.mutation.SetIssuer(v)
return _u
}
// SetNillableIssuer sets the "issuer" field if the given value is not nil.
func (_u *AuthIdentityUpdateOne) SetNillableIssuer(v *string) *AuthIdentityUpdateOne {
if v != nil {
_u.SetIssuer(*v)
}
return _u
}
// ClearIssuer clears the value of the "issuer" field.
func (_u *AuthIdentityUpdateOne) ClearIssuer() *AuthIdentityUpdateOne {
_u.mutation.ClearIssuer()
return _u
}
// SetMetadata sets the "metadata" field.
func (_u *AuthIdentityUpdateOne) SetMetadata(v map[string]interface{}) *AuthIdentityUpdateOne {
_u.mutation.SetMetadata(v)
return _u
}
// SetUser sets the "user" edge to the User entity.
func (_u *AuthIdentityUpdateOne) SetUser(v *User) *AuthIdentityUpdateOne {
return _u.SetUserID(v.ID)
}
// AddChannelIDs adds the "channels" edge to the AuthIdentityChannel entity by IDs.
func (_u *AuthIdentityUpdateOne) AddChannelIDs(ids ...int64) *AuthIdentityUpdateOne {
_u.mutation.AddChannelIDs(ids...)
return _u
}
// AddChannels adds the "channels" edges to the AuthIdentityChannel entity.
func (_u *AuthIdentityUpdateOne) AddChannels(v ...*AuthIdentityChannel) *AuthIdentityUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddChannelIDs(ids...)
}
// AddAdoptionDecisionIDs adds the "adoption_decisions" edge to the IdentityAdoptionDecision entity by IDs.
func (_u *AuthIdentityUpdateOne) AddAdoptionDecisionIDs(ids ...int64) *AuthIdentityUpdateOne {
_u.mutation.AddAdoptionDecisionIDs(ids...)
return _u
}
// AddAdoptionDecisions adds the "adoption_decisions" edges to the IdentityAdoptionDecision entity.
func (_u *AuthIdentityUpdateOne) AddAdoptionDecisions(v ...*IdentityAdoptionDecision) *AuthIdentityUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.AddAdoptionDecisionIDs(ids...)
}
// Mutation returns the AuthIdentityMutation object of the builder.
func (_u *AuthIdentityUpdateOne) Mutation() *AuthIdentityMutation {
return _u.mutation
}
// ClearUser clears the "user" edge to the User entity.
func (_u *AuthIdentityUpdateOne) ClearUser() *AuthIdentityUpdateOne {
_u.mutation.ClearUser()
return _u
}
// ClearChannels clears all "channels" edges to the AuthIdentityChannel entity.
func (_u *AuthIdentityUpdateOne) ClearChannels() *AuthIdentityUpdateOne {
_u.mutation.ClearChannels()
return _u
}
// RemoveChannelIDs removes the "channels" edge to AuthIdentityChannel entities by IDs.
func (_u *AuthIdentityUpdateOne) RemoveChannelIDs(ids ...int64) *AuthIdentityUpdateOne {
_u.mutation.RemoveChannelIDs(ids...)
return _u
}
// RemoveChannels removes "channels" edges to AuthIdentityChannel entities.
func (_u *AuthIdentityUpdateOne) RemoveChannels(v ...*AuthIdentityChannel) *AuthIdentityUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveChannelIDs(ids...)
}
// ClearAdoptionDecisions clears all "adoption_decisions" edges to the IdentityAdoptionDecision entity.
func (_u *AuthIdentityUpdateOne) ClearAdoptionDecisions() *AuthIdentityUpdateOne {
_u.mutation.ClearAdoptionDecisions()
return _u
}
// RemoveAdoptionDecisionIDs removes the "adoption_decisions" edge to IdentityAdoptionDecision entities by IDs.
func (_u *AuthIdentityUpdateOne) RemoveAdoptionDecisionIDs(ids ...int64) *AuthIdentityUpdateOne {
_u.mutation.RemoveAdoptionDecisionIDs(ids...)
return _u
}
// RemoveAdoptionDecisions removes "adoption_decisions" edges to IdentityAdoptionDecision entities.
func (_u *AuthIdentityUpdateOne) RemoveAdoptionDecisions(v ...*IdentityAdoptionDecision) *AuthIdentityUpdateOne {
ids := make([]int64, len(v))
for i := range v {
ids[i] = v[i].ID
}
return _u.RemoveAdoptionDecisionIDs(ids...)
}
// Where appends a list predicates to the AuthIdentityUpdate builder.
func (_u *AuthIdentityUpdateOne) Where(ps ...predicate.AuthIdentity) *AuthIdentityUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *AuthIdentityUpdateOne) Select(field string, fields ...string) *AuthIdentityUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AuthIdentity entity.
func (_u *AuthIdentityUpdateOne) Save(ctx context.Context) (*AuthIdentity, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthIdentityUpdateOne) SaveX(ctx context.Context) *AuthIdentity {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AuthIdentityUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthIdentityUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AuthIdentityUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := authidentity.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *AuthIdentityUpdateOne) check() error {
if v, ok := _u.mutation.ProviderType(); ok {
if err := authidentity.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_type": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderKey(); ok {
if err := authidentity.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_key": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderSubject(); ok {
if err := authidentity.ProviderSubjectValidator(v); err != nil {
return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentity.provider_subject": %w`, err)}
}
}
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "AuthIdentity.user"`)
}
return nil
}
func (_u *AuthIdentityUpdateOne) sqlSave(ctx context.Context) (_node *AuthIdentity, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(authidentity.Table, authidentity.Columns, sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthIdentity.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authidentity.FieldID)
for _, f := range fields {
if !authidentity.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != authidentity.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(authidentity.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.ProviderType(); ok {
_spec.SetField(authidentity.FieldProviderType, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderKey(); ok {
_spec.SetField(authidentity.FieldProviderKey, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderSubject(); ok {
_spec.SetField(authidentity.FieldProviderSubject, field.TypeString, value)
}
if value, ok := _u.mutation.VerifiedAt(); ok {
_spec.SetField(authidentity.FieldVerifiedAt, field.TypeTime, value)
}
if _u.mutation.VerifiedAtCleared() {
_spec.ClearField(authidentity.FieldVerifiedAt, field.TypeTime)
}
if value, ok := _u.mutation.Issuer(); ok {
_spec.SetField(authidentity.FieldIssuer, field.TypeString, value)
}
if _u.mutation.IssuerCleared() {
_spec.ClearField(authidentity.FieldIssuer, field.TypeString)
}
if value, ok := _u.mutation.Metadata(); ok {
_spec.SetField(authidentity.FieldMetadata, field.TypeJSON, value)
}
if _u.mutation.UserCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentity.UserTable,
Columns: []string{authidentity.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentity.UserTable,
Columns: []string{authidentity.UserColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.ChannelsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedChannelsIDs(); len(nodes) > 0 && !_u.mutation.ChannelsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.ChannelsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.ChannelsTable,
Columns: []string{authidentity.ChannelsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _u.mutation.AdoptionDecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.RemovedAdoptionDecisionsIDs(); len(nodes) > 0 && !_u.mutation.AdoptionDecisionsCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.AdoptionDecisionsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M,
Inverse: false,
Table: authidentity.AdoptionDecisionsTable,
Columns: []string{authidentity.AdoptionDecisionsColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &AuthIdentity{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authidentity.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
)
// AuthIdentityChannel is the model entity for the AuthIdentityChannel schema.
type AuthIdentityChannel struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// IdentityID holds the value of the "identity_id" field.
IdentityID int64 `json:"identity_id,omitempty"`
// ProviderType holds the value of the "provider_type" field.
ProviderType string `json:"provider_type,omitempty"`
// ProviderKey holds the value of the "provider_key" field.
ProviderKey string `json:"provider_key,omitempty"`
// Channel holds the value of the "channel" field.
Channel string `json:"channel,omitempty"`
// ChannelAppID holds the value of the "channel_app_id" field.
ChannelAppID string `json:"channel_app_id,omitempty"`
// ChannelSubject holds the value of the "channel_subject" field.
ChannelSubject string `json:"channel_subject,omitempty"`
// Metadata holds the value of the "metadata" field.
Metadata map[string]interface{} `json:"metadata,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the AuthIdentityChannelQuery when eager-loading is set.
Edges AuthIdentityChannelEdges `json:"edges"`
selectValues sql.SelectValues
}
// AuthIdentityChannelEdges holds the relations/edges for other nodes in the graph.
type AuthIdentityChannelEdges struct {
// Identity holds the value of the identity edge.
Identity *AuthIdentity `json:"identity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// IdentityOrErr returns the Identity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e AuthIdentityChannelEdges) IdentityOrErr() (*AuthIdentity, error) {
if e.Identity != nil {
return e.Identity, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: authidentity.Label}
}
return nil, &NotLoadedError{edge: "identity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*AuthIdentityChannel) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case authidentitychannel.FieldMetadata:
values[i] = new([]byte)
case authidentitychannel.FieldID, authidentitychannel.FieldIdentityID:
values[i] = new(sql.NullInt64)
case authidentitychannel.FieldProviderType, authidentitychannel.FieldProviderKey, authidentitychannel.FieldChannel, authidentitychannel.FieldChannelAppID, authidentitychannel.FieldChannelSubject:
values[i] = new(sql.NullString)
case authidentitychannel.FieldCreatedAt, authidentitychannel.FieldUpdatedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the AuthIdentityChannel fields.
func (_m *AuthIdentityChannel) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case authidentitychannel.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case authidentitychannel.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case authidentitychannel.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case authidentitychannel.FieldIdentityID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field identity_id", values[i])
} else if value.Valid {
_m.IdentityID = value.Int64
}
case authidentitychannel.FieldProviderType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field provider_type", values[i])
} else if value.Valid {
_m.ProviderType = value.String
}
case authidentitychannel.FieldProviderKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field provider_key", values[i])
} else if value.Valid {
_m.ProviderKey = value.String
}
case authidentitychannel.FieldChannel:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field channel", values[i])
} else if value.Valid {
_m.Channel = value.String
}
case authidentitychannel.FieldChannelAppID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field channel_app_id", values[i])
} else if value.Valid {
_m.ChannelAppID = value.String
}
case authidentitychannel.FieldChannelSubject:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field channel_subject", values[i])
} else if value.Valid {
_m.ChannelSubject = value.String
}
case authidentitychannel.FieldMetadata:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field metadata", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Metadata); err != nil {
return fmt.Errorf("unmarshal field metadata: %w", err)
}
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the AuthIdentityChannel.
// This includes values selected through modifiers, order, etc.
func (_m *AuthIdentityChannel) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryIdentity queries the "identity" edge of the AuthIdentityChannel entity.
func (_m *AuthIdentityChannel) QueryIdentity() *AuthIdentityQuery {
return NewAuthIdentityChannelClient(_m.config).QueryIdentity(_m)
}
// Update returns a builder for updating this AuthIdentityChannel.
// Note that you need to call AuthIdentityChannel.Unwrap() before calling this method if this AuthIdentityChannel
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *AuthIdentityChannel) Update() *AuthIdentityChannelUpdateOne {
return NewAuthIdentityChannelClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the AuthIdentityChannel entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *AuthIdentityChannel) Unwrap() *AuthIdentityChannel {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: AuthIdentityChannel is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *AuthIdentityChannel) String() string {
var builder strings.Builder
builder.WriteString("AuthIdentityChannel(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("identity_id=")
builder.WriteString(fmt.Sprintf("%v", _m.IdentityID))
builder.WriteString(", ")
builder.WriteString("provider_type=")
builder.WriteString(_m.ProviderType)
builder.WriteString(", ")
builder.WriteString("provider_key=")
builder.WriteString(_m.ProviderKey)
builder.WriteString(", ")
builder.WriteString("channel=")
builder.WriteString(_m.Channel)
builder.WriteString(", ")
builder.WriteString("channel_app_id=")
builder.WriteString(_m.ChannelAppID)
builder.WriteString(", ")
builder.WriteString("channel_subject=")
builder.WriteString(_m.ChannelSubject)
builder.WriteString(", ")
builder.WriteString("metadata=")
builder.WriteString(fmt.Sprintf("%v", _m.Metadata))
builder.WriteByte(')')
return builder.String()
}
// AuthIdentityChannels is a parsable slice of AuthIdentityChannel.
type AuthIdentityChannels []*AuthIdentityChannel
// Code generated by ent, DO NOT EDIT.
package authidentitychannel
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the authidentitychannel type in the database.
Label = "auth_identity_channel"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// 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"
// FieldIdentityID holds the string denoting the identity_id field in the database.
FieldIdentityID = "identity_id"
// FieldProviderType holds the string denoting the provider_type field in the database.
FieldProviderType = "provider_type"
// FieldProviderKey holds the string denoting the provider_key field in the database.
FieldProviderKey = "provider_key"
// FieldChannel holds the string denoting the channel field in the database.
FieldChannel = "channel"
// FieldChannelAppID holds the string denoting the channel_app_id field in the database.
FieldChannelAppID = "channel_app_id"
// FieldChannelSubject holds the string denoting the channel_subject field in the database.
FieldChannelSubject = "channel_subject"
// FieldMetadata holds the string denoting the metadata field in the database.
FieldMetadata = "metadata"
// EdgeIdentity holds the string denoting the identity edge name in mutations.
EdgeIdentity = "identity"
// Table holds the table name of the authidentitychannel in the database.
Table = "auth_identity_channels"
// IdentityTable is the table that holds the identity relation/edge.
IdentityTable = "auth_identity_channels"
// IdentityInverseTable is the table name for the AuthIdentity entity.
// It exists in this package in order to avoid circular dependency with the "authidentity" package.
IdentityInverseTable = "auth_identities"
// IdentityColumn is the table column denoting the identity relation/edge.
IdentityColumn = "identity_id"
)
// Columns holds all SQL columns for authidentitychannel fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldIdentityID,
FieldProviderType,
FieldProviderKey,
FieldChannel,
FieldChannelAppID,
FieldChannelSubject,
FieldMetadata,
}
// 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 (
// 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
// ProviderTypeValidator is a validator for the "provider_type" field. It is called by the builders before save.
ProviderTypeValidator func(string) error
// ProviderKeyValidator is a validator for the "provider_key" field. It is called by the builders before save.
ProviderKeyValidator func(string) error
// ChannelValidator is a validator for the "channel" field. It is called by the builders before save.
ChannelValidator func(string) error
// ChannelAppIDValidator is a validator for the "channel_app_id" field. It is called by the builders before save.
ChannelAppIDValidator func(string) error
// ChannelSubjectValidator is a validator for the "channel_subject" field. It is called by the builders before save.
ChannelSubjectValidator func(string) error
// DefaultMetadata holds the default value on creation for the "metadata" field.
DefaultMetadata func() map[string]interface{}
)
// OrderOption defines the ordering options for the AuthIdentityChannel 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()
}
// 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()
}
// ByIdentityID orders the results by the identity_id field.
func ByIdentityID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIdentityID, opts...).ToFunc()
}
// ByProviderType orders the results by the provider_type field.
func ByProviderType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProviderType, opts...).ToFunc()
}
// ByProviderKey orders the results by the provider_key field.
func ByProviderKey(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldProviderKey, opts...).ToFunc()
}
// ByChannel orders the results by the channel field.
func ByChannel(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldChannel, opts...).ToFunc()
}
// ByChannelAppID orders the results by the channel_app_id field.
func ByChannelAppID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldChannelAppID, opts...).ToFunc()
}
// ByChannelSubject orders the results by the channel_subject field.
func ByChannelSubject(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldChannelSubject, opts...).ToFunc()
}
// ByIdentityField orders the results by identity field.
func ByIdentityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newIdentityStep(), sql.OrderByField(field, opts...))
}
}
func newIdentityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(IdentityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, IdentityTable, IdentityColumn),
)
}
// Code generated by ent, DO NOT EDIT.
package authidentitychannel
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(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.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldUpdatedAt, v))
}
// IdentityID applies equality check predicate on the "identity_id" field. It's identical to IdentityIDEQ.
func IdentityID(v int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldIdentityID, v))
}
// ProviderType applies equality check predicate on the "provider_type" field. It's identical to ProviderTypeEQ.
func ProviderType(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldProviderType, v))
}
// ProviderKey applies equality check predicate on the "provider_key" field. It's identical to ProviderKeyEQ.
func ProviderKey(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldProviderKey, v))
}
// Channel applies equality check predicate on the "channel" field. It's identical to ChannelEQ.
func Channel(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannel, v))
}
// ChannelAppID applies equality check predicate on the "channel_app_id" field. It's identical to ChannelAppIDEQ.
func ChannelAppID(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannelAppID, v))
}
// ChannelSubject applies equality check predicate on the "channel_subject" field. It's identical to ChannelSubjectEQ.
func ChannelSubject(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannelSubject, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldUpdatedAt, v))
}
// IdentityIDEQ applies the EQ predicate on the "identity_id" field.
func IdentityIDEQ(v int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldIdentityID, v))
}
// IdentityIDNEQ applies the NEQ predicate on the "identity_id" field.
func IdentityIDNEQ(v int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldIdentityID, v))
}
// IdentityIDIn applies the In predicate on the "identity_id" field.
func IdentityIDIn(vs ...int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldIdentityID, vs...))
}
// IdentityIDNotIn applies the NotIn predicate on the "identity_id" field.
func IdentityIDNotIn(vs ...int64) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldIdentityID, vs...))
}
// ProviderTypeEQ applies the EQ predicate on the "provider_type" field.
func ProviderTypeEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldProviderType, v))
}
// ProviderTypeNEQ applies the NEQ predicate on the "provider_type" field.
func ProviderTypeNEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldProviderType, v))
}
// ProviderTypeIn applies the In predicate on the "provider_type" field.
func ProviderTypeIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldProviderType, vs...))
}
// ProviderTypeNotIn applies the NotIn predicate on the "provider_type" field.
func ProviderTypeNotIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldProviderType, vs...))
}
// ProviderTypeGT applies the GT predicate on the "provider_type" field.
func ProviderTypeGT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldProviderType, v))
}
// ProviderTypeGTE applies the GTE predicate on the "provider_type" field.
func ProviderTypeGTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldProviderType, v))
}
// ProviderTypeLT applies the LT predicate on the "provider_type" field.
func ProviderTypeLT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldProviderType, v))
}
// ProviderTypeLTE applies the LTE predicate on the "provider_type" field.
func ProviderTypeLTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldProviderType, v))
}
// ProviderTypeContains applies the Contains predicate on the "provider_type" field.
func ProviderTypeContains(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContains(FieldProviderType, v))
}
// ProviderTypeHasPrefix applies the HasPrefix predicate on the "provider_type" field.
func ProviderTypeHasPrefix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasPrefix(FieldProviderType, v))
}
// ProviderTypeHasSuffix applies the HasSuffix predicate on the "provider_type" field.
func ProviderTypeHasSuffix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasSuffix(FieldProviderType, v))
}
// ProviderTypeEqualFold applies the EqualFold predicate on the "provider_type" field.
func ProviderTypeEqualFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEqualFold(FieldProviderType, v))
}
// ProviderTypeContainsFold applies the ContainsFold predicate on the "provider_type" field.
func ProviderTypeContainsFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContainsFold(FieldProviderType, v))
}
// ProviderKeyEQ applies the EQ predicate on the "provider_key" field.
func ProviderKeyEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldProviderKey, v))
}
// ProviderKeyNEQ applies the NEQ predicate on the "provider_key" field.
func ProviderKeyNEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldProviderKey, v))
}
// ProviderKeyIn applies the In predicate on the "provider_key" field.
func ProviderKeyIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldProviderKey, vs...))
}
// ProviderKeyNotIn applies the NotIn predicate on the "provider_key" field.
func ProviderKeyNotIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldProviderKey, vs...))
}
// ProviderKeyGT applies the GT predicate on the "provider_key" field.
func ProviderKeyGT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldProviderKey, v))
}
// ProviderKeyGTE applies the GTE predicate on the "provider_key" field.
func ProviderKeyGTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldProviderKey, v))
}
// ProviderKeyLT applies the LT predicate on the "provider_key" field.
func ProviderKeyLT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldProviderKey, v))
}
// ProviderKeyLTE applies the LTE predicate on the "provider_key" field.
func ProviderKeyLTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldProviderKey, v))
}
// ProviderKeyContains applies the Contains predicate on the "provider_key" field.
func ProviderKeyContains(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContains(FieldProviderKey, v))
}
// ProviderKeyHasPrefix applies the HasPrefix predicate on the "provider_key" field.
func ProviderKeyHasPrefix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasPrefix(FieldProviderKey, v))
}
// ProviderKeyHasSuffix applies the HasSuffix predicate on the "provider_key" field.
func ProviderKeyHasSuffix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasSuffix(FieldProviderKey, v))
}
// ProviderKeyEqualFold applies the EqualFold predicate on the "provider_key" field.
func ProviderKeyEqualFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEqualFold(FieldProviderKey, v))
}
// ProviderKeyContainsFold applies the ContainsFold predicate on the "provider_key" field.
func ProviderKeyContainsFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContainsFold(FieldProviderKey, v))
}
// ChannelEQ applies the EQ predicate on the "channel" field.
func ChannelEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannel, v))
}
// ChannelNEQ applies the NEQ predicate on the "channel" field.
func ChannelNEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldChannel, v))
}
// ChannelIn applies the In predicate on the "channel" field.
func ChannelIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldChannel, vs...))
}
// ChannelNotIn applies the NotIn predicate on the "channel" field.
func ChannelNotIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldChannel, vs...))
}
// ChannelGT applies the GT predicate on the "channel" field.
func ChannelGT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldChannel, v))
}
// ChannelGTE applies the GTE predicate on the "channel" field.
func ChannelGTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldChannel, v))
}
// ChannelLT applies the LT predicate on the "channel" field.
func ChannelLT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldChannel, v))
}
// ChannelLTE applies the LTE predicate on the "channel" field.
func ChannelLTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldChannel, v))
}
// ChannelContains applies the Contains predicate on the "channel" field.
func ChannelContains(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContains(FieldChannel, v))
}
// ChannelHasPrefix applies the HasPrefix predicate on the "channel" field.
func ChannelHasPrefix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasPrefix(FieldChannel, v))
}
// ChannelHasSuffix applies the HasSuffix predicate on the "channel" field.
func ChannelHasSuffix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasSuffix(FieldChannel, v))
}
// ChannelEqualFold applies the EqualFold predicate on the "channel" field.
func ChannelEqualFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEqualFold(FieldChannel, v))
}
// ChannelContainsFold applies the ContainsFold predicate on the "channel" field.
func ChannelContainsFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContainsFold(FieldChannel, v))
}
// ChannelAppIDEQ applies the EQ predicate on the "channel_app_id" field.
func ChannelAppIDEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannelAppID, v))
}
// ChannelAppIDNEQ applies the NEQ predicate on the "channel_app_id" field.
func ChannelAppIDNEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldChannelAppID, v))
}
// ChannelAppIDIn applies the In predicate on the "channel_app_id" field.
func ChannelAppIDIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldChannelAppID, vs...))
}
// ChannelAppIDNotIn applies the NotIn predicate on the "channel_app_id" field.
func ChannelAppIDNotIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldChannelAppID, vs...))
}
// ChannelAppIDGT applies the GT predicate on the "channel_app_id" field.
func ChannelAppIDGT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldChannelAppID, v))
}
// ChannelAppIDGTE applies the GTE predicate on the "channel_app_id" field.
func ChannelAppIDGTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldChannelAppID, v))
}
// ChannelAppIDLT applies the LT predicate on the "channel_app_id" field.
func ChannelAppIDLT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldChannelAppID, v))
}
// ChannelAppIDLTE applies the LTE predicate on the "channel_app_id" field.
func ChannelAppIDLTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldChannelAppID, v))
}
// ChannelAppIDContains applies the Contains predicate on the "channel_app_id" field.
func ChannelAppIDContains(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContains(FieldChannelAppID, v))
}
// ChannelAppIDHasPrefix applies the HasPrefix predicate on the "channel_app_id" field.
func ChannelAppIDHasPrefix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasPrefix(FieldChannelAppID, v))
}
// ChannelAppIDHasSuffix applies the HasSuffix predicate on the "channel_app_id" field.
func ChannelAppIDHasSuffix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasSuffix(FieldChannelAppID, v))
}
// ChannelAppIDEqualFold applies the EqualFold predicate on the "channel_app_id" field.
func ChannelAppIDEqualFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEqualFold(FieldChannelAppID, v))
}
// ChannelAppIDContainsFold applies the ContainsFold predicate on the "channel_app_id" field.
func ChannelAppIDContainsFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContainsFold(FieldChannelAppID, v))
}
// ChannelSubjectEQ applies the EQ predicate on the "channel_subject" field.
func ChannelSubjectEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEQ(FieldChannelSubject, v))
}
// ChannelSubjectNEQ applies the NEQ predicate on the "channel_subject" field.
func ChannelSubjectNEQ(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNEQ(FieldChannelSubject, v))
}
// ChannelSubjectIn applies the In predicate on the "channel_subject" field.
func ChannelSubjectIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldIn(FieldChannelSubject, vs...))
}
// ChannelSubjectNotIn applies the NotIn predicate on the "channel_subject" field.
func ChannelSubjectNotIn(vs ...string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldNotIn(FieldChannelSubject, vs...))
}
// ChannelSubjectGT applies the GT predicate on the "channel_subject" field.
func ChannelSubjectGT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGT(FieldChannelSubject, v))
}
// ChannelSubjectGTE applies the GTE predicate on the "channel_subject" field.
func ChannelSubjectGTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldGTE(FieldChannelSubject, v))
}
// ChannelSubjectLT applies the LT predicate on the "channel_subject" field.
func ChannelSubjectLT(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLT(FieldChannelSubject, v))
}
// ChannelSubjectLTE applies the LTE predicate on the "channel_subject" field.
func ChannelSubjectLTE(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldLTE(FieldChannelSubject, v))
}
// ChannelSubjectContains applies the Contains predicate on the "channel_subject" field.
func ChannelSubjectContains(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContains(FieldChannelSubject, v))
}
// ChannelSubjectHasPrefix applies the HasPrefix predicate on the "channel_subject" field.
func ChannelSubjectHasPrefix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasPrefix(FieldChannelSubject, v))
}
// ChannelSubjectHasSuffix applies the HasSuffix predicate on the "channel_subject" field.
func ChannelSubjectHasSuffix(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldHasSuffix(FieldChannelSubject, v))
}
// ChannelSubjectEqualFold applies the EqualFold predicate on the "channel_subject" field.
func ChannelSubjectEqualFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldEqualFold(FieldChannelSubject, v))
}
// ChannelSubjectContainsFold applies the ContainsFold predicate on the "channel_subject" field.
func ChannelSubjectContainsFold(v string) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.FieldContainsFold(FieldChannelSubject, v))
}
// HasIdentity applies the HasEdge predicate on the "identity" edge.
func HasIdentity() predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, IdentityTable, IdentityColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasIdentityWith applies the HasEdge predicate on the "identity" edge with a given conditions (other predicates).
func HasIdentityWith(preds ...predicate.AuthIdentity) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(func(s *sql.Selector) {
step := newIdentityStep()
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.AuthIdentityChannel) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.AuthIdentityChannel) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.AuthIdentityChannel) predicate.AuthIdentityChannel {
return predicate.AuthIdentityChannel(sql.NotPredicates(p))
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
)
// AuthIdentityChannelCreate is the builder for creating a AuthIdentityChannel entity.
type AuthIdentityChannelCreate struct {
config
mutation *AuthIdentityChannelMutation
hooks []Hook
conflict []sql.ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func (_c *AuthIdentityChannelCreate) SetCreatedAt(v time.Time) *AuthIdentityChannelCreate {
_c.mutation.SetCreatedAt(v)
return _c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *AuthIdentityChannelCreate) SetNillableCreatedAt(v *time.Time) *AuthIdentityChannelCreate {
if v != nil {
_c.SetCreatedAt(*v)
}
return _c
}
// SetUpdatedAt sets the "updated_at" field.
func (_c *AuthIdentityChannelCreate) SetUpdatedAt(v time.Time) *AuthIdentityChannelCreate {
_c.mutation.SetUpdatedAt(v)
return _c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (_c *AuthIdentityChannelCreate) SetNillableUpdatedAt(v *time.Time) *AuthIdentityChannelCreate {
if v != nil {
_c.SetUpdatedAt(*v)
}
return _c
}
// SetIdentityID sets the "identity_id" field.
func (_c *AuthIdentityChannelCreate) SetIdentityID(v int64) *AuthIdentityChannelCreate {
_c.mutation.SetIdentityID(v)
return _c
}
// SetProviderType sets the "provider_type" field.
func (_c *AuthIdentityChannelCreate) SetProviderType(v string) *AuthIdentityChannelCreate {
_c.mutation.SetProviderType(v)
return _c
}
// SetProviderKey sets the "provider_key" field.
func (_c *AuthIdentityChannelCreate) SetProviderKey(v string) *AuthIdentityChannelCreate {
_c.mutation.SetProviderKey(v)
return _c
}
// SetChannel sets the "channel" field.
func (_c *AuthIdentityChannelCreate) SetChannel(v string) *AuthIdentityChannelCreate {
_c.mutation.SetChannel(v)
return _c
}
// SetChannelAppID sets the "channel_app_id" field.
func (_c *AuthIdentityChannelCreate) SetChannelAppID(v string) *AuthIdentityChannelCreate {
_c.mutation.SetChannelAppID(v)
return _c
}
// SetChannelSubject sets the "channel_subject" field.
func (_c *AuthIdentityChannelCreate) SetChannelSubject(v string) *AuthIdentityChannelCreate {
_c.mutation.SetChannelSubject(v)
return _c
}
// SetMetadata sets the "metadata" field.
func (_c *AuthIdentityChannelCreate) SetMetadata(v map[string]interface{}) *AuthIdentityChannelCreate {
_c.mutation.SetMetadata(v)
return _c
}
// SetIdentity sets the "identity" edge to the AuthIdentity entity.
func (_c *AuthIdentityChannelCreate) SetIdentity(v *AuthIdentity) *AuthIdentityChannelCreate {
return _c.SetIdentityID(v.ID)
}
// Mutation returns the AuthIdentityChannelMutation object of the builder.
func (_c *AuthIdentityChannelCreate) Mutation() *AuthIdentityChannelMutation {
return _c.mutation
}
// Save creates the AuthIdentityChannel in the database.
func (_c *AuthIdentityChannelCreate) Save(ctx context.Context) (*AuthIdentityChannel, error) {
_c.defaults()
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
}
// SaveX calls Save and panics if Save returns an error.
func (_c *AuthIdentityChannelCreate) SaveX(ctx context.Context) *AuthIdentityChannel {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AuthIdentityChannelCreate) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AuthIdentityChannelCreate) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_c *AuthIdentityChannelCreate) defaults() {
if _, ok := _c.mutation.CreatedAt(); !ok {
v := authidentitychannel.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
v := authidentitychannel.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.Metadata(); !ok {
v := authidentitychannel.DefaultMetadata()
_c.mutation.SetMetadata(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_c *AuthIdentityChannelCreate) check() error {
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "AuthIdentityChannel.created_at"`)}
}
if _, ok := _c.mutation.UpdatedAt(); !ok {
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "AuthIdentityChannel.updated_at"`)}
}
if _, ok := _c.mutation.IdentityID(); !ok {
return &ValidationError{Name: "identity_id", err: errors.New(`ent: missing required field "AuthIdentityChannel.identity_id"`)}
}
if _, ok := _c.mutation.ProviderType(); !ok {
return &ValidationError{Name: "provider_type", err: errors.New(`ent: missing required field "AuthIdentityChannel.provider_type"`)}
}
if v, ok := _c.mutation.ProviderType(); ok {
if err := authidentitychannel.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_type": %w`, err)}
}
}
if _, ok := _c.mutation.ProviderKey(); !ok {
return &ValidationError{Name: "provider_key", err: errors.New(`ent: missing required field "AuthIdentityChannel.provider_key"`)}
}
if v, ok := _c.mutation.ProviderKey(); ok {
if err := authidentitychannel.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_key": %w`, err)}
}
}
if _, ok := _c.mutation.Channel(); !ok {
return &ValidationError{Name: "channel", err: errors.New(`ent: missing required field "AuthIdentityChannel.channel"`)}
}
if v, ok := _c.mutation.Channel(); ok {
if err := authidentitychannel.ChannelValidator(v); err != nil {
return &ValidationError{Name: "channel", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel": %w`, err)}
}
}
if _, ok := _c.mutation.ChannelAppID(); !ok {
return &ValidationError{Name: "channel_app_id", err: errors.New(`ent: missing required field "AuthIdentityChannel.channel_app_id"`)}
}
if v, ok := _c.mutation.ChannelAppID(); ok {
if err := authidentitychannel.ChannelAppIDValidator(v); err != nil {
return &ValidationError{Name: "channel_app_id", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_app_id": %w`, err)}
}
}
if _, ok := _c.mutation.ChannelSubject(); !ok {
return &ValidationError{Name: "channel_subject", err: errors.New(`ent: missing required field "AuthIdentityChannel.channel_subject"`)}
}
if v, ok := _c.mutation.ChannelSubject(); ok {
if err := authidentitychannel.ChannelSubjectValidator(v); err != nil {
return &ValidationError{Name: "channel_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_subject": %w`, err)}
}
}
if _, ok := _c.mutation.Metadata(); !ok {
return &ValidationError{Name: "metadata", err: errors.New(`ent: missing required field "AuthIdentityChannel.metadata"`)}
}
if len(_c.mutation.IdentityIDs()) == 0 {
return &ValidationError{Name: "identity", err: errors.New(`ent: missing required edge "AuthIdentityChannel.identity"`)}
}
return nil
}
func (_c *AuthIdentityChannelCreate) sqlSave(ctx context.Context) (*AuthIdentityChannel, error) {
if err := _c.check(); err != nil {
return nil, err
}
_node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
id := _spec.ID.Value.(int64)
_node.ID = int64(id)
_c.mutation.id = &_node.ID
_c.mutation.done = true
return _node, nil
}
func (_c *AuthIdentityChannelCreate) createSpec() (*AuthIdentityChannel, *sqlgraph.CreateSpec) {
var (
_node = &AuthIdentityChannel{config: _c.config}
_spec = sqlgraph.NewCreateSpec(authidentitychannel.Table, sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64))
)
_spec.OnConflict = _c.conflict
if value, ok := _c.mutation.CreatedAt(); ok {
_spec.SetField(authidentitychannel.FieldCreatedAt, field.TypeTime, value)
_node.CreatedAt = value
}
if value, ok := _c.mutation.UpdatedAt(); ok {
_spec.SetField(authidentitychannel.FieldUpdatedAt, field.TypeTime, value)
_node.UpdatedAt = value
}
if value, ok := _c.mutation.ProviderType(); ok {
_spec.SetField(authidentitychannel.FieldProviderType, field.TypeString, value)
_node.ProviderType = value
}
if value, ok := _c.mutation.ProviderKey(); ok {
_spec.SetField(authidentitychannel.FieldProviderKey, field.TypeString, value)
_node.ProviderKey = value
}
if value, ok := _c.mutation.Channel(); ok {
_spec.SetField(authidentitychannel.FieldChannel, field.TypeString, value)
_node.Channel = value
}
if value, ok := _c.mutation.ChannelAppID(); ok {
_spec.SetField(authidentitychannel.FieldChannelAppID, field.TypeString, value)
_node.ChannelAppID = value
}
if value, ok := _c.mutation.ChannelSubject(); ok {
_spec.SetField(authidentitychannel.FieldChannelSubject, field.TypeString, value)
_node.ChannelSubject = value
}
if value, ok := _c.mutation.Metadata(); ok {
_spec.SetField(authidentitychannel.FieldMetadata, field.TypeJSON, value)
_node.Metadata = value
}
if nodes := _c.mutation.IdentityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentitychannel.IdentityTable,
Columns: []string{authidentitychannel.IdentityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_node.IdentityID = nodes[0]
_spec.Edges = append(_spec.Edges, edge)
}
return _node, _spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AuthIdentityChannel.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AuthIdentityChannelUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AuthIdentityChannelCreate) OnConflict(opts ...sql.ConflictOption) *AuthIdentityChannelUpsertOne {
_c.conflict = opts
return &AuthIdentityChannelUpsertOne{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AuthIdentityChannelCreate) OnConflictColumns(columns ...string) *AuthIdentityChannelUpsertOne {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AuthIdentityChannelUpsertOne{
create: _c,
}
}
type (
// AuthIdentityChannelUpsertOne is the builder for "upsert"-ing
// one AuthIdentityChannel node.
AuthIdentityChannelUpsertOne struct {
create *AuthIdentityChannelCreate
}
// AuthIdentityChannelUpsert is the "OnConflict" setter.
AuthIdentityChannelUpsert struct {
*sql.UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityChannelUpsert) SetUpdatedAt(v time.Time) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldUpdatedAt, v)
return u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateUpdatedAt() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldUpdatedAt)
return u
}
// SetIdentityID sets the "identity_id" field.
func (u *AuthIdentityChannelUpsert) SetIdentityID(v int64) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldIdentityID, v)
return u
}
// UpdateIdentityID sets the "identity_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateIdentityID() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldIdentityID)
return u
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityChannelUpsert) SetProviderType(v string) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldProviderType, v)
return u
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateProviderType() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldProviderType)
return u
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityChannelUpsert) SetProviderKey(v string) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldProviderKey, v)
return u
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateProviderKey() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldProviderKey)
return u
}
// SetChannel sets the "channel" field.
func (u *AuthIdentityChannelUpsert) SetChannel(v string) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldChannel, v)
return u
}
// UpdateChannel sets the "channel" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateChannel() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldChannel)
return u
}
// SetChannelAppID sets the "channel_app_id" field.
func (u *AuthIdentityChannelUpsert) SetChannelAppID(v string) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldChannelAppID, v)
return u
}
// UpdateChannelAppID sets the "channel_app_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateChannelAppID() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldChannelAppID)
return u
}
// SetChannelSubject sets the "channel_subject" field.
func (u *AuthIdentityChannelUpsert) SetChannelSubject(v string) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldChannelSubject, v)
return u
}
// UpdateChannelSubject sets the "channel_subject" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateChannelSubject() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldChannelSubject)
return u
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityChannelUpsert) SetMetadata(v map[string]interface{}) *AuthIdentityChannelUpsert {
u.Set(authidentitychannel.FieldMetadata, v)
return u
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsert) UpdateMetadata() *AuthIdentityChannelUpsert {
u.SetExcluded(authidentitychannel.FieldMetadata)
return u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AuthIdentityChannelUpsertOne) UpdateNewValues() *AuthIdentityChannelUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
if _, exists := u.create.mutation.CreatedAt(); exists {
s.SetIgnore(authidentitychannel.FieldCreatedAt)
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AuthIdentityChannelUpsertOne) Ignore() *AuthIdentityChannelUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AuthIdentityChannelUpsertOne) DoNothing() *AuthIdentityChannelUpsertOne {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AuthIdentityChannelCreate.OnConflict
// documentation for more info.
func (u *AuthIdentityChannelUpsertOne) Update(set func(*AuthIdentityChannelUpsert)) *AuthIdentityChannelUpsertOne {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AuthIdentityChannelUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityChannelUpsertOne) SetUpdatedAt(v time.Time) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateUpdatedAt() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateUpdatedAt()
})
}
// SetIdentityID sets the "identity_id" field.
func (u *AuthIdentityChannelUpsertOne) SetIdentityID(v int64) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetIdentityID(v)
})
}
// UpdateIdentityID sets the "identity_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateIdentityID() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateIdentityID()
})
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityChannelUpsertOne) SetProviderType(v string) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetProviderType(v)
})
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateProviderType() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateProviderType()
})
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityChannelUpsertOne) SetProviderKey(v string) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetProviderKey(v)
})
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateProviderKey() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateProviderKey()
})
}
// SetChannel sets the "channel" field.
func (u *AuthIdentityChannelUpsertOne) SetChannel(v string) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannel(v)
})
}
// UpdateChannel sets the "channel" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateChannel() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannel()
})
}
// SetChannelAppID sets the "channel_app_id" field.
func (u *AuthIdentityChannelUpsertOne) SetChannelAppID(v string) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannelAppID(v)
})
}
// UpdateChannelAppID sets the "channel_app_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateChannelAppID() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannelAppID()
})
}
// SetChannelSubject sets the "channel_subject" field.
func (u *AuthIdentityChannelUpsertOne) SetChannelSubject(v string) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannelSubject(v)
})
}
// UpdateChannelSubject sets the "channel_subject" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateChannelSubject() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannelSubject()
})
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityChannelUpsertOne) SetMetadata(v map[string]interface{}) *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetMetadata(v)
})
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertOne) UpdateMetadata() *AuthIdentityChannelUpsertOne {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateMetadata()
})
}
// Exec executes the query.
func (u *AuthIdentityChannelUpsertOne) Exec(ctx context.Context) error {
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AuthIdentityChannelCreate.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AuthIdentityChannelUpsertOne) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *AuthIdentityChannelUpsertOne) ID(ctx context.Context) (id int64, err error) {
node, err := u.create.Save(ctx)
if err != nil {
return id, err
}
return node.ID, nil
}
// IDX is like ID, but panics if an error occurs.
func (u *AuthIdentityChannelUpsertOne) IDX(ctx context.Context) int64 {
id, err := u.ID(ctx)
if err != nil {
panic(err)
}
return id
}
// AuthIdentityChannelCreateBulk is the builder for creating many AuthIdentityChannel entities in bulk.
type AuthIdentityChannelCreateBulk struct {
config
err error
builders []*AuthIdentityChannelCreate
conflict []sql.ConflictOption
}
// Save creates the AuthIdentityChannel entities in the database.
func (_c *AuthIdentityChannelCreateBulk) Save(ctx context.Context) ([]*AuthIdentityChannel, error) {
if _c.err != nil {
return nil, _c.err
}
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
nodes := make([]*AuthIdentityChannel, len(_c.builders))
mutators := make([]Mutator, len(_c.builders))
for i := range _c.builders {
func(i int, root context.Context) {
builder := _c.builders[i]
builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*AuthIdentityChannelMutation)
if !ok {
return nil, fmt.Errorf("unexpected mutation type %T", m)
}
if err := builder.check(); err != nil {
return nil, err
}
builder.mutation = mutation
var err error
nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 {
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
} else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
spec.OnConflict = _c.conflict
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
if err != nil {
return nil, err
}
mutation.id = &nodes[i].ID
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {
mut = builder.hooks[i](mut)
}
mutators[i] = mut
}(i, ctx)
}
if len(mutators) > 0 {
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
return nil, err
}
}
return nodes, nil
}
// SaveX is like Save, but panics if an error occurs.
func (_c *AuthIdentityChannelCreateBulk) SaveX(ctx context.Context) []*AuthIdentityChannel {
v, err := _c.Save(ctx)
if err != nil {
panic(err)
}
return v
}
// Exec executes the query.
func (_c *AuthIdentityChannelCreateBulk) Exec(ctx context.Context) error {
_, err := _c.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_c *AuthIdentityChannelCreateBulk) ExecX(ctx context.Context) {
if err := _c.Exec(ctx); err != nil {
panic(err)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.AuthIdentityChannel.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.AuthIdentityChannelUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func (_c *AuthIdentityChannelCreateBulk) OnConflict(opts ...sql.ConflictOption) *AuthIdentityChannelUpsertBulk {
_c.conflict = opts
return &AuthIdentityChannelUpsertBulk{
create: _c,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func (_c *AuthIdentityChannelCreateBulk) OnConflictColumns(columns ...string) *AuthIdentityChannelUpsertBulk {
_c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
return &AuthIdentityChannelUpsertBulk{
create: _c,
}
}
// AuthIdentityChannelUpsertBulk is the builder for "upsert"-ing
// a bulk of AuthIdentityChannel nodes.
type AuthIdentityChannelUpsertBulk struct {
create *AuthIdentityChannelCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func (u *AuthIdentityChannelUpsertBulk) UpdateNewValues() *AuthIdentityChannelUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
for _, b := range u.create.builders {
if _, exists := b.mutation.CreatedAt(); exists {
s.SetIgnore(authidentitychannel.FieldCreatedAt)
}
}
}))
return u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.AuthIdentityChannel.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func (u *AuthIdentityChannelUpsertBulk) Ignore() *AuthIdentityChannelUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
return u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *AuthIdentityChannelUpsertBulk) DoNothing() *AuthIdentityChannelUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.DoNothing())
return u
}
// Update allows overriding fields `UPDATE` values. See the AuthIdentityChannelCreateBulk.OnConflict
// documentation for more info.
func (u *AuthIdentityChannelUpsertBulk) Update(set func(*AuthIdentityChannelUpsert)) *AuthIdentityChannelUpsertBulk {
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
set(&AuthIdentityChannelUpsert{UpdateSet: update})
}))
return u
}
// SetUpdatedAt sets the "updated_at" field.
func (u *AuthIdentityChannelUpsertBulk) SetUpdatedAt(v time.Time) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetUpdatedAt(v)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateUpdatedAt() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateUpdatedAt()
})
}
// SetIdentityID sets the "identity_id" field.
func (u *AuthIdentityChannelUpsertBulk) SetIdentityID(v int64) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetIdentityID(v)
})
}
// UpdateIdentityID sets the "identity_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateIdentityID() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateIdentityID()
})
}
// SetProviderType sets the "provider_type" field.
func (u *AuthIdentityChannelUpsertBulk) SetProviderType(v string) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetProviderType(v)
})
}
// UpdateProviderType sets the "provider_type" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateProviderType() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateProviderType()
})
}
// SetProviderKey sets the "provider_key" field.
func (u *AuthIdentityChannelUpsertBulk) SetProviderKey(v string) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetProviderKey(v)
})
}
// UpdateProviderKey sets the "provider_key" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateProviderKey() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateProviderKey()
})
}
// SetChannel sets the "channel" field.
func (u *AuthIdentityChannelUpsertBulk) SetChannel(v string) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannel(v)
})
}
// UpdateChannel sets the "channel" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateChannel() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannel()
})
}
// SetChannelAppID sets the "channel_app_id" field.
func (u *AuthIdentityChannelUpsertBulk) SetChannelAppID(v string) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannelAppID(v)
})
}
// UpdateChannelAppID sets the "channel_app_id" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateChannelAppID() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannelAppID()
})
}
// SetChannelSubject sets the "channel_subject" field.
func (u *AuthIdentityChannelUpsertBulk) SetChannelSubject(v string) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetChannelSubject(v)
})
}
// UpdateChannelSubject sets the "channel_subject" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateChannelSubject() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateChannelSubject()
})
}
// SetMetadata sets the "metadata" field.
func (u *AuthIdentityChannelUpsertBulk) SetMetadata(v map[string]interface{}) *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.SetMetadata(v)
})
}
// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *AuthIdentityChannelUpsertBulk) UpdateMetadata() *AuthIdentityChannelUpsertBulk {
return u.Update(func(s *AuthIdentityChannelUpsert) {
s.UpdateMetadata()
})
}
// Exec executes the query.
func (u *AuthIdentityChannelUpsertBulk) Exec(ctx context.Context) error {
if u.create.err != nil {
return u.create.err
}
for i, b := range u.create.builders {
if len(b.conflict) != 0 {
return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the AuthIdentityChannelCreateBulk instead", i)
}
}
if len(u.create.conflict) == 0 {
return errors.New("ent: missing options for AuthIdentityChannelCreateBulk.OnConflict")
}
return u.create.Exec(ctx)
}
// ExecX is like Exec, but panics if an error occurs.
func (u *AuthIdentityChannelUpsertBulk) ExecX(ctx context.Context) {
if err := u.create.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AuthIdentityChannelDelete is the builder for deleting a AuthIdentityChannel entity.
type AuthIdentityChannelDelete struct {
config
hooks []Hook
mutation *AuthIdentityChannelMutation
}
// Where appends a list predicates to the AuthIdentityChannelDelete builder.
func (_d *AuthIdentityChannelDelete) Where(ps ...predicate.AuthIdentityChannel) *AuthIdentityChannelDelete {
_d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func (_d *AuthIdentityChannelDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AuthIdentityChannelDelete) ExecX(ctx context.Context) int {
n, err := _d.Exec(ctx)
if err != nil {
panic(err)
}
return n
}
func (_d *AuthIdentityChannelDelete) sqlExec(ctx context.Context) (int, error) {
_spec := sqlgraph.NewDeleteSpec(authidentitychannel.Table, sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64))
if ps := _d.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
_d.mutation.done = true
return affected, err
}
// AuthIdentityChannelDeleteOne is the builder for deleting a single AuthIdentityChannel entity.
type AuthIdentityChannelDeleteOne struct {
_d *AuthIdentityChannelDelete
}
// Where appends a list predicates to the AuthIdentityChannelDelete builder.
func (_d *AuthIdentityChannelDeleteOne) Where(ps ...predicate.AuthIdentityChannel) *AuthIdentityChannelDeleteOne {
_d._d.mutation.Where(ps...)
return _d
}
// Exec executes the deletion query.
func (_d *AuthIdentityChannelDeleteOne) Exec(ctx context.Context) error {
n, err := _d._d.Exec(ctx)
switch {
case err != nil:
return err
case n == 0:
return &NotFoundError{authidentitychannel.Label}
default:
return nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func (_d *AuthIdentityChannelDeleteOne) ExecX(ctx context.Context) {
if err := _d.Exec(ctx); err != nil {
panic(err)
}
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AuthIdentityChannelQuery is the builder for querying AuthIdentityChannel entities.
type AuthIdentityChannelQuery struct {
config
ctx *QueryContext
order []authidentitychannel.OrderOption
inters []Interceptor
predicates []predicate.AuthIdentityChannel
withIdentity *AuthIdentityQuery
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
}
// Where adds a new predicate for the AuthIdentityChannelQuery builder.
func (_q *AuthIdentityChannelQuery) Where(ps ...predicate.AuthIdentityChannel) *AuthIdentityChannelQuery {
_q.predicates = append(_q.predicates, ps...)
return _q
}
// Limit the number of records to be returned by this query.
func (_q *AuthIdentityChannelQuery) Limit(limit int) *AuthIdentityChannelQuery {
_q.ctx.Limit = &limit
return _q
}
// Offset to start from.
func (_q *AuthIdentityChannelQuery) Offset(offset int) *AuthIdentityChannelQuery {
_q.ctx.Offset = &offset
return _q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func (_q *AuthIdentityChannelQuery) Unique(unique bool) *AuthIdentityChannelQuery {
_q.ctx.Unique = &unique
return _q
}
// Order specifies how the records should be ordered.
func (_q *AuthIdentityChannelQuery) Order(o ...authidentitychannel.OrderOption) *AuthIdentityChannelQuery {
_q.order = append(_q.order, o...)
return _q
}
// QueryIdentity chains the current query on the "identity" edge.
func (_q *AuthIdentityChannelQuery) QueryIdentity() *AuthIdentityQuery {
query := (&AuthIdentityClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil {
return nil, err
}
step := sqlgraph.NewStep(
sqlgraph.From(authidentitychannel.Table, authidentitychannel.FieldID, selector),
sqlgraph.To(authidentity.Table, authidentity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, authidentitychannel.IdentityTable, authidentitychannel.IdentityColumn),
)
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
return fromU, nil
}
return query
}
// First returns the first AuthIdentityChannel entity from the query.
// Returns a *NotFoundError when no AuthIdentityChannel was found.
func (_q *AuthIdentityChannelQuery) First(ctx context.Context) (*AuthIdentityChannel, error) {
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil {
return nil, err
}
if len(nodes) == 0 {
return nil, &NotFoundError{authidentitychannel.Label}
}
return nodes[0], nil
}
// FirstX is like First, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) FirstX(ctx context.Context) *AuthIdentityChannel {
node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return node
}
// FirstID returns the first AuthIdentityChannel ID from the query.
// Returns a *NotFoundError when no AuthIdentityChannel ID was found.
func (_q *AuthIdentityChannelQuery) FirstID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
return
}
if len(ids) == 0 {
err = &NotFoundError{authidentitychannel.Label}
return
}
return ids[0], nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) FirstIDX(ctx context.Context) int64 {
id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) {
panic(err)
}
return id
}
// Only returns a single AuthIdentityChannel entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one AuthIdentityChannel entity is found.
// Returns a *NotFoundError when no AuthIdentityChannel entities are found.
func (_q *AuthIdentityChannelQuery) Only(ctx context.Context) (*AuthIdentityChannel, error) {
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil {
return nil, err
}
switch len(nodes) {
case 1:
return nodes[0], nil
case 0:
return nil, &NotFoundError{authidentitychannel.Label}
default:
return nil, &NotSingularError{authidentitychannel.Label}
}
}
// OnlyX is like Only, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) OnlyX(ctx context.Context) *AuthIdentityChannel {
node, err := _q.Only(ctx)
if err != nil {
panic(err)
}
return node
}
// OnlyID is like Only, but returns the only AuthIdentityChannel ID in the query.
// Returns a *NotSingularError when more than one AuthIdentityChannel ID is found.
// Returns a *NotFoundError when no entities are found.
func (_q *AuthIdentityChannelQuery) OnlyID(ctx context.Context) (id int64, err error) {
var ids []int64
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
return
}
switch len(ids) {
case 1:
id = ids[0]
case 0:
err = &NotFoundError{authidentitychannel.Label}
default:
err = &NotSingularError{authidentitychannel.Label}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) OnlyIDX(ctx context.Context) int64 {
id, err := _q.OnlyID(ctx)
if err != nil {
panic(err)
}
return id
}
// All executes the query and returns a list of AuthIdentityChannels.
func (_q *AuthIdentityChannelQuery) All(ctx context.Context) ([]*AuthIdentityChannel, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := _q.prepareQuery(ctx); err != nil {
return nil, err
}
qr := querierAll[[]*AuthIdentityChannel, *AuthIdentityChannelQuery]()
return withInterceptors[[]*AuthIdentityChannel](ctx, _q, qr, _q.inters)
}
// AllX is like All, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) AllX(ctx context.Context) []*AuthIdentityChannel {
nodes, err := _q.All(ctx)
if err != nil {
panic(err)
}
return nodes
}
// IDs executes the query and returns a list of AuthIdentityChannel IDs.
func (_q *AuthIdentityChannelQuery) IDs(ctx context.Context) (ids []int64, err error) {
if _q.ctx.Unique == nil && _q.path != nil {
_q.Unique(true)
}
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = _q.Select(authidentitychannel.FieldID).Scan(ctx, &ids); err != nil {
return nil, err
}
return ids, nil
}
// IDsX is like IDs, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) IDsX(ctx context.Context) []int64 {
ids, err := _q.IDs(ctx)
if err != nil {
panic(err)
}
return ids
}
// Count returns the count of the given query.
func (_q *AuthIdentityChannelQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := _q.prepareQuery(ctx); err != nil {
return 0, err
}
return withInterceptors[int](ctx, _q, querierCount[*AuthIdentityChannelQuery](), _q.inters)
}
// CountX is like Count, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) CountX(ctx context.Context) int {
count, err := _q.Count(ctx)
if err != nil {
panic(err)
}
return count
}
// Exist returns true if the query has elements in the graph.
func (_q *AuthIdentityChannelQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := _q.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func (_q *AuthIdentityChannelQuery) ExistX(ctx context.Context) bool {
exist, err := _q.Exist(ctx)
if err != nil {
panic(err)
}
return exist
}
// Clone returns a duplicate of the AuthIdentityChannelQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func (_q *AuthIdentityChannelQuery) Clone() *AuthIdentityChannelQuery {
if _q == nil {
return nil
}
return &AuthIdentityChannelQuery{
config: _q.config,
ctx: _q.ctx.Clone(),
order: append([]authidentitychannel.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.AuthIdentityChannel{}, _q.predicates...),
withIdentity: _q.withIdentity.Clone(),
// clone intermediate query.
sql: _q.sql.Clone(),
path: _q.path,
}
}
// WithIdentity tells the query-builder to eager-load the nodes that are connected to
// the "identity" edge. The optional arguments are used to configure the query builder of the edge.
func (_q *AuthIdentityChannelQuery) WithIdentity(opts ...func(*AuthIdentityQuery)) *AuthIdentityChannelQuery {
query := (&AuthIdentityClient{config: _q.config}).Query()
for _, opt := range opts {
opt(query)
}
_q.withIdentity = query
return _q
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.AuthIdentityChannel.Query().
// GroupBy(authidentitychannel.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func (_q *AuthIdentityChannelQuery) GroupBy(field string, fields ...string) *AuthIdentityChannelGroupBy {
_q.ctx.Fields = append([]string{field}, fields...)
grbuild := &AuthIdentityChannelGroupBy{build: _q}
grbuild.flds = &_q.ctx.Fields
grbuild.label = authidentitychannel.Label
grbuild.scan = grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.AuthIdentityChannel.Query().
// Select(authidentitychannel.FieldCreatedAt).
// Scan(ctx, &v)
func (_q *AuthIdentityChannelQuery) Select(fields ...string) *AuthIdentityChannelSelect {
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &AuthIdentityChannelSelect{AuthIdentityChannelQuery: _q}
sbuild.label = authidentitychannel.Label
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild
}
// Aggregate returns a AuthIdentityChannelSelect configured with the given aggregations.
func (_q *AuthIdentityChannelQuery) Aggregate(fns ...AggregateFunc) *AuthIdentityChannelSelect {
return _q.Select().Aggregate(fns...)
}
func (_q *AuthIdentityChannelQuery) prepareQuery(ctx context.Context) error {
for _, inter := range _q.inters {
if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
}
if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, _q); err != nil {
return err
}
}
}
for _, f := range _q.ctx.Fields {
if !authidentitychannel.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
}
if _q.path != nil {
prev, err := _q.path(ctx)
if err != nil {
return err
}
_q.sql = prev
}
return nil
}
func (_q *AuthIdentityChannelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*AuthIdentityChannel, error) {
var (
nodes = []*AuthIdentityChannel{}
_spec = _q.querySpec()
loadedTypes = [1]bool{
_q.withIdentity != nil,
}
)
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*AuthIdentityChannel).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []any) error {
node := &AuthIdentityChannel{config: _q.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := _q.withIdentity; query != nil {
if err := _q.loadIdentity(ctx, query, nodes, nil,
func(n *AuthIdentityChannel, e *AuthIdentity) { n.Edges.Identity = e }); err != nil {
return nil, err
}
}
return nodes, nil
}
func (_q *AuthIdentityChannelQuery) loadIdentity(ctx context.Context, query *AuthIdentityQuery, nodes []*AuthIdentityChannel, init func(*AuthIdentityChannel), assign func(*AuthIdentityChannel, *AuthIdentity)) error {
ids := make([]int64, 0, len(nodes))
nodeids := make(map[int64][]*AuthIdentityChannel)
for i := range nodes {
fk := nodes[i].IdentityID
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
if len(ids) == 0 {
return nil
}
query.Where(authidentity.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "identity_id" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (_q *AuthIdentityChannelQuery) sqlCount(ctx context.Context) (int, error) {
_spec := _q.querySpec()
if len(_q.modifiers) > 0 {
_spec.Modifiers = _q.modifiers
}
_spec.Node.Columns = _q.ctx.Fields
if len(_q.ctx.Fields) > 0 {
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
}
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
}
func (_q *AuthIdentityChannelQuery) querySpec() *sqlgraph.QuerySpec {
_spec := sqlgraph.NewQuerySpec(authidentitychannel.Table, authidentitychannel.Columns, sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64))
_spec.From = _q.sql
if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique
} else if _q.path != nil {
_spec.Unique = true
}
if fields := _q.ctx.Fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authidentitychannel.FieldID)
for i := range fields {
if fields[i] != authidentitychannel.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
}
}
if _q.withIdentity != nil {
_spec.Node.AddColumnOnce(authidentitychannel.FieldIdentityID)
}
}
if ps := _q.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit
}
if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset
}
if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
return _spec
}
func (_q *AuthIdentityChannelQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(authidentitychannel.Table)
columns := _q.ctx.Fields
if len(columns) == 0 {
columns = authidentitychannel.Columns
}
selector := builder.Select(t1.Columns(columns...)...).From(t1)
if _q.sql != nil {
selector = _q.sql
selector.Select(selector.Columns(columns...)...)
}
if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct()
}
for _, m := range _q.modifiers {
m(selector)
}
for _, p := range _q.predicates {
p(selector)
}
for _, p := range _q.order {
p(selector)
}
if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit)
}
return selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func (_q *AuthIdentityChannelQuery) ForUpdate(opts ...sql.LockOption) *AuthIdentityChannelQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForUpdate(opts...)
})
return _q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func (_q *AuthIdentityChannelQuery) ForShare(opts ...sql.LockOption) *AuthIdentityChannelQuery {
if _q.driver.Dialect() == dialect.Postgres {
_q.Unique(false)
}
_q.modifiers = append(_q.modifiers, func(s *sql.Selector) {
s.ForShare(opts...)
})
return _q
}
// AuthIdentityChannelGroupBy is the group-by builder for AuthIdentityChannel entities.
type AuthIdentityChannelGroupBy struct {
selector
build *AuthIdentityChannelQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func (_g *AuthIdentityChannelGroupBy) Aggregate(fns ...AggregateFunc) *AuthIdentityChannelGroupBy {
_g.fns = append(_g.fns, fns...)
return _g
}
// Scan applies the selector query and scans the result into the given value.
func (_g *AuthIdentityChannelGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := _g.build.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AuthIdentityChannelQuery, *AuthIdentityChannelGroupBy](ctx, _g.build, _g, _g.build.inters, v)
}
func (_g *AuthIdentityChannelGroupBy) sqlScan(ctx context.Context, root *AuthIdentityChannelQuery, v any) error {
selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(_g.fns))
for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector))
}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *_g.flds {
columns = append(columns, selector.C(f))
}
columns = append(columns, aggregation...)
selector.Select(columns...)
}
selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil {
return err
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// AuthIdentityChannelSelect is the builder for selecting fields of AuthIdentityChannel entities.
type AuthIdentityChannelSelect struct {
*AuthIdentityChannelQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (_s *AuthIdentityChannelSelect) Aggregate(fns ...AggregateFunc) *AuthIdentityChannelSelect {
_s.fns = append(_s.fns, fns...)
return _s
}
// Scan applies the selector query and scans the result into the given value.
func (_s *AuthIdentityChannelSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := _s.prepareQuery(ctx); err != nil {
return err
}
return scanWithInterceptors[*AuthIdentityChannelQuery, *AuthIdentityChannelSelect](ctx, _s.AuthIdentityChannelQuery, _s, _s.inters, v)
}
func (_s *AuthIdentityChannelSelect) sqlScan(ctx context.Context, root *AuthIdentityChannelQuery, v any) error {
selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(_s.fns))
for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector))
}
switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
selector.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := selector.Query()
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
return err
}
defer rows.Close()
return sql.ScanSlice(rows, v)
}
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// AuthIdentityChannelUpdate is the builder for updating AuthIdentityChannel entities.
type AuthIdentityChannelUpdate struct {
config
hooks []Hook
mutation *AuthIdentityChannelMutation
}
// Where appends a list predicates to the AuthIdentityChannelUpdate builder.
func (_u *AuthIdentityChannelUpdate) Where(ps ...predicate.AuthIdentityChannel) *AuthIdentityChannelUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AuthIdentityChannelUpdate) SetUpdatedAt(v time.Time) *AuthIdentityChannelUpdate {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetIdentityID sets the "identity_id" field.
func (_u *AuthIdentityChannelUpdate) SetIdentityID(v int64) *AuthIdentityChannelUpdate {
_u.mutation.SetIdentityID(v)
return _u
}
// SetNillableIdentityID sets the "identity_id" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableIdentityID(v *int64) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetIdentityID(*v)
}
return _u
}
// SetProviderType sets the "provider_type" field.
func (_u *AuthIdentityChannelUpdate) SetProviderType(v string) *AuthIdentityChannelUpdate {
_u.mutation.SetProviderType(v)
return _u
}
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableProviderType(v *string) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetProviderType(*v)
}
return _u
}
// SetProviderKey sets the "provider_key" field.
func (_u *AuthIdentityChannelUpdate) SetProviderKey(v string) *AuthIdentityChannelUpdate {
_u.mutation.SetProviderKey(v)
return _u
}
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableProviderKey(v *string) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetProviderKey(*v)
}
return _u
}
// SetChannel sets the "channel" field.
func (_u *AuthIdentityChannelUpdate) SetChannel(v string) *AuthIdentityChannelUpdate {
_u.mutation.SetChannel(v)
return _u
}
// SetNillableChannel sets the "channel" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableChannel(v *string) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetChannel(*v)
}
return _u
}
// SetChannelAppID sets the "channel_app_id" field.
func (_u *AuthIdentityChannelUpdate) SetChannelAppID(v string) *AuthIdentityChannelUpdate {
_u.mutation.SetChannelAppID(v)
return _u
}
// SetNillableChannelAppID sets the "channel_app_id" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableChannelAppID(v *string) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetChannelAppID(*v)
}
return _u
}
// SetChannelSubject sets the "channel_subject" field.
func (_u *AuthIdentityChannelUpdate) SetChannelSubject(v string) *AuthIdentityChannelUpdate {
_u.mutation.SetChannelSubject(v)
return _u
}
// SetNillableChannelSubject sets the "channel_subject" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdate) SetNillableChannelSubject(v *string) *AuthIdentityChannelUpdate {
if v != nil {
_u.SetChannelSubject(*v)
}
return _u
}
// SetMetadata sets the "metadata" field.
func (_u *AuthIdentityChannelUpdate) SetMetadata(v map[string]interface{}) *AuthIdentityChannelUpdate {
_u.mutation.SetMetadata(v)
return _u
}
// SetIdentity sets the "identity" edge to the AuthIdentity entity.
func (_u *AuthIdentityChannelUpdate) SetIdentity(v *AuthIdentity) *AuthIdentityChannelUpdate {
return _u.SetIdentityID(v.ID)
}
// Mutation returns the AuthIdentityChannelMutation object of the builder.
func (_u *AuthIdentityChannelUpdate) Mutation() *AuthIdentityChannelMutation {
return _u.mutation
}
// ClearIdentity clears the "identity" edge to the AuthIdentity entity.
func (_u *AuthIdentityChannelUpdate) ClearIdentity() *AuthIdentityChannelUpdate {
_u.mutation.ClearIdentity()
return _u
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AuthIdentityChannelUpdate) Save(ctx context.Context) (int, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthIdentityChannelUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AuthIdentityChannelUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthIdentityChannelUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AuthIdentityChannelUpdate) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := authidentitychannel.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *AuthIdentityChannelUpdate) check() error {
if v, ok := _u.mutation.ProviderType(); ok {
if err := authidentitychannel.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_type": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderKey(); ok {
if err := authidentitychannel.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_key": %w`, err)}
}
}
if v, ok := _u.mutation.Channel(); ok {
if err := authidentitychannel.ChannelValidator(v); err != nil {
return &ValidationError{Name: "channel", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel": %w`, err)}
}
}
if v, ok := _u.mutation.ChannelAppID(); ok {
if err := authidentitychannel.ChannelAppIDValidator(v); err != nil {
return &ValidationError{Name: "channel_app_id", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_app_id": %w`, err)}
}
}
if v, ok := _u.mutation.ChannelSubject(); ok {
if err := authidentitychannel.ChannelSubjectValidator(v); err != nil {
return &ValidationError{Name: "channel_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_subject": %w`, err)}
}
}
if _u.mutation.IdentityCleared() && len(_u.mutation.IdentityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "AuthIdentityChannel.identity"`)
}
return nil
}
func (_u *AuthIdentityChannelUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(authidentitychannel.Table, authidentitychannel.Columns, sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64))
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(authidentitychannel.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.ProviderType(); ok {
_spec.SetField(authidentitychannel.FieldProviderType, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderKey(); ok {
_spec.SetField(authidentitychannel.FieldProviderKey, field.TypeString, value)
}
if value, ok := _u.mutation.Channel(); ok {
_spec.SetField(authidentitychannel.FieldChannel, field.TypeString, value)
}
if value, ok := _u.mutation.ChannelAppID(); ok {
_spec.SetField(authidentitychannel.FieldChannelAppID, field.TypeString, value)
}
if value, ok := _u.mutation.ChannelSubject(); ok {
_spec.SetField(authidentitychannel.FieldChannelSubject, field.TypeString, value)
}
if value, ok := _u.mutation.Metadata(); ok {
_spec.SetField(authidentitychannel.FieldMetadata, field.TypeJSON, value)
}
if _u.mutation.IdentityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentitychannel.IdentityTable,
Columns: []string{authidentitychannel.IdentityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.IdentityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentitychannel.IdentityTable,
Columns: []string{authidentitychannel.IdentityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authidentitychannel.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AuthIdentityChannelUpdateOne is the builder for updating a single AuthIdentityChannel entity.
type AuthIdentityChannelUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AuthIdentityChannelMutation
}
// SetUpdatedAt sets the "updated_at" field.
func (_u *AuthIdentityChannelUpdateOne) SetUpdatedAt(v time.Time) *AuthIdentityChannelUpdateOne {
_u.mutation.SetUpdatedAt(v)
return _u
}
// SetIdentityID sets the "identity_id" field.
func (_u *AuthIdentityChannelUpdateOne) SetIdentityID(v int64) *AuthIdentityChannelUpdateOne {
_u.mutation.SetIdentityID(v)
return _u
}
// SetNillableIdentityID sets the "identity_id" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableIdentityID(v *int64) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetIdentityID(*v)
}
return _u
}
// SetProviderType sets the "provider_type" field.
func (_u *AuthIdentityChannelUpdateOne) SetProviderType(v string) *AuthIdentityChannelUpdateOne {
_u.mutation.SetProviderType(v)
return _u
}
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableProviderType(v *string) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetProviderType(*v)
}
return _u
}
// SetProviderKey sets the "provider_key" field.
func (_u *AuthIdentityChannelUpdateOne) SetProviderKey(v string) *AuthIdentityChannelUpdateOne {
_u.mutation.SetProviderKey(v)
return _u
}
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableProviderKey(v *string) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetProviderKey(*v)
}
return _u
}
// SetChannel sets the "channel" field.
func (_u *AuthIdentityChannelUpdateOne) SetChannel(v string) *AuthIdentityChannelUpdateOne {
_u.mutation.SetChannel(v)
return _u
}
// SetNillableChannel sets the "channel" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableChannel(v *string) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetChannel(*v)
}
return _u
}
// SetChannelAppID sets the "channel_app_id" field.
func (_u *AuthIdentityChannelUpdateOne) SetChannelAppID(v string) *AuthIdentityChannelUpdateOne {
_u.mutation.SetChannelAppID(v)
return _u
}
// SetNillableChannelAppID sets the "channel_app_id" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableChannelAppID(v *string) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetChannelAppID(*v)
}
return _u
}
// SetChannelSubject sets the "channel_subject" field.
func (_u *AuthIdentityChannelUpdateOne) SetChannelSubject(v string) *AuthIdentityChannelUpdateOne {
_u.mutation.SetChannelSubject(v)
return _u
}
// SetNillableChannelSubject sets the "channel_subject" field if the given value is not nil.
func (_u *AuthIdentityChannelUpdateOne) SetNillableChannelSubject(v *string) *AuthIdentityChannelUpdateOne {
if v != nil {
_u.SetChannelSubject(*v)
}
return _u
}
// SetMetadata sets the "metadata" field.
func (_u *AuthIdentityChannelUpdateOne) SetMetadata(v map[string]interface{}) *AuthIdentityChannelUpdateOne {
_u.mutation.SetMetadata(v)
return _u
}
// SetIdentity sets the "identity" edge to the AuthIdentity entity.
func (_u *AuthIdentityChannelUpdateOne) SetIdentity(v *AuthIdentity) *AuthIdentityChannelUpdateOne {
return _u.SetIdentityID(v.ID)
}
// Mutation returns the AuthIdentityChannelMutation object of the builder.
func (_u *AuthIdentityChannelUpdateOne) Mutation() *AuthIdentityChannelMutation {
return _u.mutation
}
// ClearIdentity clears the "identity" edge to the AuthIdentity entity.
func (_u *AuthIdentityChannelUpdateOne) ClearIdentity() *AuthIdentityChannelUpdateOne {
_u.mutation.ClearIdentity()
return _u
}
// Where appends a list predicates to the AuthIdentityChannelUpdate builder.
func (_u *AuthIdentityChannelUpdateOne) Where(ps ...predicate.AuthIdentityChannel) *AuthIdentityChannelUpdateOne {
_u.mutation.Where(ps...)
return _u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func (_u *AuthIdentityChannelUpdateOne) Select(field string, fields ...string) *AuthIdentityChannelUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AuthIdentityChannel entity.
func (_u *AuthIdentityChannelUpdateOne) Save(ctx context.Context) (*AuthIdentityChannel, error) {
_u.defaults()
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthIdentityChannelUpdateOne) SaveX(ctx context.Context) *AuthIdentityChannel {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AuthIdentityChannelUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthIdentityChannelUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
// defaults sets the default values of the builder before save.
func (_u *AuthIdentityChannelUpdateOne) defaults() {
if _, ok := _u.mutation.UpdatedAt(); !ok {
v := authidentitychannel.UpdateDefaultUpdatedAt()
_u.mutation.SetUpdatedAt(v)
}
}
// check runs all checks and user-defined validators on the builder.
func (_u *AuthIdentityChannelUpdateOne) check() error {
if v, ok := _u.mutation.ProviderType(); ok {
if err := authidentitychannel.ProviderTypeValidator(v); err != nil {
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_type": %w`, err)}
}
}
if v, ok := _u.mutation.ProviderKey(); ok {
if err := authidentitychannel.ProviderKeyValidator(v); err != nil {
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.provider_key": %w`, err)}
}
}
if v, ok := _u.mutation.Channel(); ok {
if err := authidentitychannel.ChannelValidator(v); err != nil {
return &ValidationError{Name: "channel", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel": %w`, err)}
}
}
if v, ok := _u.mutation.ChannelAppID(); ok {
if err := authidentitychannel.ChannelAppIDValidator(v); err != nil {
return &ValidationError{Name: "channel_app_id", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_app_id": %w`, err)}
}
}
if v, ok := _u.mutation.ChannelSubject(); ok {
if err := authidentitychannel.ChannelSubjectValidator(v); err != nil {
return &ValidationError{Name: "channel_subject", err: fmt.Errorf(`ent: validator failed for field "AuthIdentityChannel.channel_subject": %w`, err)}
}
}
if _u.mutation.IdentityCleared() && len(_u.mutation.IdentityIDs()) > 0 {
return errors.New(`ent: clearing a required unique edge "AuthIdentityChannel.identity"`)
}
return nil
}
func (_u *AuthIdentityChannelUpdateOne) sqlSave(ctx context.Context) (_node *AuthIdentityChannel, err error) {
if err := _u.check(); err != nil {
return _node, err
}
_spec := sqlgraph.NewUpdateSpec(authidentitychannel.Table, authidentitychannel.Columns, sqlgraph.NewFieldSpec(authidentitychannel.FieldID, field.TypeInt64))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AuthIdentityChannel.id" for update`)}
}
_spec.Node.ID.Value = id
if fields := _u.fields; len(fields) > 0 {
_spec.Node.Columns = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, authidentitychannel.FieldID)
for _, f := range fields {
if !authidentitychannel.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
}
if f != authidentitychannel.FieldID {
_spec.Node.Columns = append(_spec.Node.Columns, f)
}
}
}
if ps := _u.mutation.predicates; len(ps) > 0 {
_spec.Predicate = func(selector *sql.Selector) {
for i := range ps {
ps[i](selector)
}
}
}
if value, ok := _u.mutation.UpdatedAt(); ok {
_spec.SetField(authidentitychannel.FieldUpdatedAt, field.TypeTime, value)
}
if value, ok := _u.mutation.ProviderType(); ok {
_spec.SetField(authidentitychannel.FieldProviderType, field.TypeString, value)
}
if value, ok := _u.mutation.ProviderKey(); ok {
_spec.SetField(authidentitychannel.FieldProviderKey, field.TypeString, value)
}
if value, ok := _u.mutation.Channel(); ok {
_spec.SetField(authidentitychannel.FieldChannel, field.TypeString, value)
}
if value, ok := _u.mutation.ChannelAppID(); ok {
_spec.SetField(authidentitychannel.FieldChannelAppID, field.TypeString, value)
}
if value, ok := _u.mutation.ChannelSubject(); ok {
_spec.SetField(authidentitychannel.FieldChannelSubject, field.TypeString, value)
}
if value, ok := _u.mutation.Metadata(); ok {
_spec.SetField(authidentitychannel.FieldMetadata, field.TypeJSON, value)
}
if _u.mutation.IdentityCleared() {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentitychannel.IdentityTable,
Columns: []string{authidentitychannel.IdentityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
},
}
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
}
if nodes := _u.mutation.IdentityIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O,
Inverse: true,
Table: authidentitychannel.IdentityTable,
Columns: []string{authidentitychannel.IdentityColumn},
Bidi: false,
Target: &sqlgraph.EdgeTarget{
IDSpec: sqlgraph.NewFieldSpec(authidentity.FieldID, field.TypeInt64),
},
}
for _, k := range nodes {
edge.Target.Nodes = append(edge.Target.Nodes, k)
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_node = &AuthIdentityChannel{config: _u.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authidentitychannel.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}
......@@ -20,12 +20,16 @@ import (
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
"github.com/Wei-Shaw/sub2api/ent/paymentorder"
"github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance"
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
......@@ -60,18 +64,26 @@ type Client struct {
Announcement *AnnouncementClient
// AnnouncementRead is the client for interacting with the AnnouncementRead builders.
AnnouncementRead *AnnouncementReadClient
// AuthIdentity is the client for interacting with the AuthIdentity builders.
AuthIdentity *AuthIdentityClient
// AuthIdentityChannel is the client for interacting with the AuthIdentityChannel builders.
AuthIdentityChannel *AuthIdentityChannelClient
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
ErrorPassthroughRule *ErrorPassthroughRuleClient
// Group is the client for interacting with the Group builders.
Group *GroupClient
// IdempotencyRecord is the client for interacting with the IdempotencyRecord builders.
IdempotencyRecord *IdempotencyRecordClient
// IdentityAdoptionDecision is the client for interacting with the IdentityAdoptionDecision builders.
IdentityAdoptionDecision *IdentityAdoptionDecisionClient
// PaymentAuditLog is the client for interacting with the PaymentAuditLog builders.
PaymentAuditLog *PaymentAuditLogClient
// PaymentOrder is the client for interacting with the PaymentOrder builders.
PaymentOrder *PaymentOrderClient
// PaymentProviderInstance is the client for interacting with the PaymentProviderInstance builders.
PaymentProviderInstance *PaymentProviderInstanceClient
// PendingAuthSession is the client for interacting with the PendingAuthSession builders.
PendingAuthSession *PendingAuthSessionClient
// PromoCode is the client for interacting with the PromoCode builders.
PromoCode *PromoCodeClient
// PromoCodeUsage is the client for interacting with the PromoCodeUsage builders.
......@@ -118,12 +130,16 @@ func (c *Client) init() {
c.AccountGroup = NewAccountGroupClient(c.config)
c.Announcement = NewAnnouncementClient(c.config)
c.AnnouncementRead = NewAnnouncementReadClient(c.config)
c.AuthIdentity = NewAuthIdentityClient(c.config)
c.AuthIdentityChannel = NewAuthIdentityChannelClient(c.config)
c.ErrorPassthroughRule = NewErrorPassthroughRuleClient(c.config)
c.Group = NewGroupClient(c.config)
c.IdempotencyRecord = NewIdempotencyRecordClient(c.config)
c.IdentityAdoptionDecision = NewIdentityAdoptionDecisionClient(c.config)
c.PaymentAuditLog = NewPaymentAuditLogClient(c.config)
c.PaymentOrder = NewPaymentOrderClient(c.config)
c.PaymentProviderInstance = NewPaymentProviderInstanceClient(c.config)
c.PendingAuthSession = NewPendingAuthSessionClient(c.config)
c.PromoCode = NewPromoCodeClient(c.config)
c.PromoCodeUsage = NewPromoCodeUsageClient(c.config)
c.Proxy = NewProxyClient(c.config)
......@@ -236,12 +252,16 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
AccountGroup: NewAccountGroupClient(cfg),
Announcement: NewAnnouncementClient(cfg),
AnnouncementRead: NewAnnouncementReadClient(cfg),
AuthIdentity: NewAuthIdentityClient(cfg),
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
Group: NewGroupClient(cfg),
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
PaymentOrder: NewPaymentOrderClient(cfg),
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
PendingAuthSession: NewPendingAuthSessionClient(cfg),
PromoCode: NewPromoCodeClient(cfg),
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
Proxy: NewProxyClient(cfg),
......@@ -281,12 +301,16 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
AccountGroup: NewAccountGroupClient(cfg),
Announcement: NewAnnouncementClient(cfg),
AnnouncementRead: NewAnnouncementReadClient(cfg),
AuthIdentity: NewAuthIdentityClient(cfg),
AuthIdentityChannel: NewAuthIdentityChannelClient(cfg),
ErrorPassthroughRule: NewErrorPassthroughRuleClient(cfg),
Group: NewGroupClient(cfg),
IdempotencyRecord: NewIdempotencyRecordClient(cfg),
IdentityAdoptionDecision: NewIdentityAdoptionDecisionClient(cfg),
PaymentAuditLog: NewPaymentAuditLogClient(cfg),
PaymentOrder: NewPaymentOrderClient(cfg),
PaymentProviderInstance: NewPaymentProviderInstanceClient(cfg),
PendingAuthSession: NewPendingAuthSessionClient(cfg),
PromoCode: NewPromoCodeClient(cfg),
PromoCodeUsage: NewPromoCodeUsageClient(cfg),
Proxy: NewProxyClient(cfg),
......@@ -332,11 +356,12 @@ func (c *Client) Close() error {
func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, c.PromoCodeUsage,
c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan,
c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User,
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.AuthIdentity, c.AuthIdentityChannel, c.ErrorPassthroughRule, c.Group,
c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.UserSubscription,
} {
n.Use(hooks...)
......@@ -348,11 +373,12 @@ func (c *Client) Use(hooks ...Hook) {
func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.APIKey, c.Account, c.AccountGroup, c.Announcement, c.AnnouncementRead,
c.ErrorPassthroughRule, c.Group, c.IdempotencyRecord, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PromoCode, c.PromoCodeUsage,
c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting, c.SubscriptionPlan,
c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog, c.User,
c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.AuthIdentity, c.AuthIdentityChannel, c.ErrorPassthroughRule, c.Group,
c.IdempotencyRecord, c.IdentityAdoptionDecision, c.PaymentAuditLog,
c.PaymentOrder, c.PaymentProviderInstance, c.PendingAuthSession, c.PromoCode,
c.PromoCodeUsage, c.Proxy, c.RedeemCode, c.SecuritySecret, c.Setting,
c.SubscriptionPlan, c.TLSFingerprintProfile, c.UsageCleanupTask, c.UsageLog,
c.User, c.UserAllowedGroup, c.UserAttributeDefinition, c.UserAttributeValue,
c.UserSubscription,
} {
n.Intercept(interceptors...)
......@@ -372,18 +398,26 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.Announcement.mutate(ctx, m)
case *AnnouncementReadMutation:
return c.AnnouncementRead.mutate(ctx, m)
case *AuthIdentityMutation:
return c.AuthIdentity.mutate(ctx, m)
case *AuthIdentityChannelMutation:
return c.AuthIdentityChannel.mutate(ctx, m)
case *ErrorPassthroughRuleMutation:
return c.ErrorPassthroughRule.mutate(ctx, m)
case *GroupMutation:
return c.Group.mutate(ctx, m)
case *IdempotencyRecordMutation:
return c.IdempotencyRecord.mutate(ctx, m)
case *IdentityAdoptionDecisionMutation:
return c.IdentityAdoptionDecision.mutate(ctx, m)
case *PaymentAuditLogMutation:
return c.PaymentAuditLog.mutate(ctx, m)
case *PaymentOrderMutation:
return c.PaymentOrder.mutate(ctx, m)
case *PaymentProviderInstanceMutation:
return c.PaymentProviderInstance.mutate(ctx, m)
case *PendingAuthSessionMutation:
return c.PendingAuthSession.mutate(ctx, m)
case *PromoCodeMutation:
return c.PromoCode.mutate(ctx, m)
case *PromoCodeUsageMutation:
......@@ -1231,6 +1265,336 @@ func (c *AnnouncementReadClient) mutate(ctx context.Context, m *AnnouncementRead
}
}
// AuthIdentityClient is a client for the AuthIdentity schema.
type AuthIdentityClient struct {
config
}
// NewAuthIdentityClient returns a client for the AuthIdentity from the given config.
func NewAuthIdentityClient(c config) *AuthIdentityClient {
return &AuthIdentityClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `authidentity.Hooks(f(g(h())))`.
func (c *AuthIdentityClient) Use(hooks ...Hook) {
c.hooks.AuthIdentity = append(c.hooks.AuthIdentity, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authidentity.Intercept(f(g(h())))`.
func (c *AuthIdentityClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthIdentity = append(c.inters.AuthIdentity, interceptors...)
}
// Create returns a builder for creating a AuthIdentity entity.
func (c *AuthIdentityClient) Create() *AuthIdentityCreate {
mutation := newAuthIdentityMutation(c.config, OpCreate)
return &AuthIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of AuthIdentity entities.
func (c *AuthIdentityClient) CreateBulk(builders ...*AuthIdentityCreate) *AuthIdentityCreateBulk {
return &AuthIdentityCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *AuthIdentityClient) MapCreateBulk(slice any, setFunc func(*AuthIdentityCreate, int)) *AuthIdentityCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &AuthIdentityCreateBulk{err: fmt.Errorf("calling to AuthIdentityClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*AuthIdentityCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &AuthIdentityCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for AuthIdentity.
func (c *AuthIdentityClient) Update() *AuthIdentityUpdate {
mutation := newAuthIdentityMutation(c.config, OpUpdate)
return &AuthIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *AuthIdentityClient) UpdateOne(_m *AuthIdentity) *AuthIdentityUpdateOne {
mutation := newAuthIdentityMutation(c.config, OpUpdateOne, withAuthIdentity(_m))
return &AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *AuthIdentityClient) UpdateOneID(id int64) *AuthIdentityUpdateOne {
mutation := newAuthIdentityMutation(c.config, OpUpdateOne, withAuthIdentityID(id))
return &AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for AuthIdentity.
func (c *AuthIdentityClient) Delete() *AuthIdentityDelete {
mutation := newAuthIdentityMutation(c.config, OpDelete)
return &AuthIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *AuthIdentityClient) DeleteOne(_m *AuthIdentity) *AuthIdentityDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *AuthIdentityClient) DeleteOneID(id int64) *AuthIdentityDeleteOne {
builder := c.Delete().Where(authidentity.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &AuthIdentityDeleteOne{builder}
}
// Query returns a query builder for AuthIdentity.
func (c *AuthIdentityClient) Query() *AuthIdentityQuery {
return &AuthIdentityQuery{
config: c.config,
ctx: &QueryContext{Type: TypeAuthIdentity},
inters: c.Interceptors(),
}
}
// Get returns a AuthIdentity entity by its id.
func (c *AuthIdentityClient) Get(ctx context.Context, id int64) (*AuthIdentity, error) {
return c.Query().Where(authidentity.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *AuthIdentityClient) GetX(ctx context.Context, id int64) *AuthIdentity {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryUser queries the user edge of a AuthIdentity.
func (c *AuthIdentityClient) QueryUser(_m *AuthIdentity) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, authidentity.UserTable, authidentity.UserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryChannels queries the channels edge of a AuthIdentity.
func (c *AuthIdentityClient) QueryChannels(_m *AuthIdentity) *AuthIdentityChannelQuery {
query := (&AuthIdentityChannelClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
sqlgraph.To(authidentitychannel.Table, authidentitychannel.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, authidentity.ChannelsTable, authidentity.ChannelsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryAdoptionDecisions queries the adoption_decisions edge of a AuthIdentity.
func (c *AuthIdentityClient) QueryAdoptionDecisions(_m *AuthIdentity) *IdentityAdoptionDecisionQuery {
query := (&IdentityAdoptionDecisionClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(authidentity.Table, authidentity.FieldID, id),
sqlgraph.To(identityadoptiondecision.Table, identityadoptiondecision.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, authidentity.AdoptionDecisionsTable, authidentity.AdoptionDecisionsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *AuthIdentityClient) Hooks() []Hook {
return c.hooks.AuthIdentity
}
// Interceptors returns the client interceptors.
func (c *AuthIdentityClient) Interceptors() []Interceptor {
return c.inters.AuthIdentity
}
func (c *AuthIdentityClient) mutate(ctx context.Context, m *AuthIdentityMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&AuthIdentityCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&AuthIdentityUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&AuthIdentityUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&AuthIdentityDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown AuthIdentity mutation op: %q", m.Op())
}
}
// AuthIdentityChannelClient is a client for the AuthIdentityChannel schema.
type AuthIdentityChannelClient struct {
config
}
// NewAuthIdentityChannelClient returns a client for the AuthIdentityChannel from the given config.
func NewAuthIdentityChannelClient(c config) *AuthIdentityChannelClient {
return &AuthIdentityChannelClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `authidentitychannel.Hooks(f(g(h())))`.
func (c *AuthIdentityChannelClient) Use(hooks ...Hook) {
c.hooks.AuthIdentityChannel = append(c.hooks.AuthIdentityChannel, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `authidentitychannel.Intercept(f(g(h())))`.
func (c *AuthIdentityChannelClient) Intercept(interceptors ...Interceptor) {
c.inters.AuthIdentityChannel = append(c.inters.AuthIdentityChannel, interceptors...)
}
// Create returns a builder for creating a AuthIdentityChannel entity.
func (c *AuthIdentityChannelClient) Create() *AuthIdentityChannelCreate {
mutation := newAuthIdentityChannelMutation(c.config, OpCreate)
return &AuthIdentityChannelCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of AuthIdentityChannel entities.
func (c *AuthIdentityChannelClient) CreateBulk(builders ...*AuthIdentityChannelCreate) *AuthIdentityChannelCreateBulk {
return &AuthIdentityChannelCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *AuthIdentityChannelClient) MapCreateBulk(slice any, setFunc func(*AuthIdentityChannelCreate, int)) *AuthIdentityChannelCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &AuthIdentityChannelCreateBulk{err: fmt.Errorf("calling to AuthIdentityChannelClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*AuthIdentityChannelCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &AuthIdentityChannelCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for AuthIdentityChannel.
func (c *AuthIdentityChannelClient) Update() *AuthIdentityChannelUpdate {
mutation := newAuthIdentityChannelMutation(c.config, OpUpdate)
return &AuthIdentityChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *AuthIdentityChannelClient) UpdateOne(_m *AuthIdentityChannel) *AuthIdentityChannelUpdateOne {
mutation := newAuthIdentityChannelMutation(c.config, OpUpdateOne, withAuthIdentityChannel(_m))
return &AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *AuthIdentityChannelClient) UpdateOneID(id int64) *AuthIdentityChannelUpdateOne {
mutation := newAuthIdentityChannelMutation(c.config, OpUpdateOne, withAuthIdentityChannelID(id))
return &AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for AuthIdentityChannel.
func (c *AuthIdentityChannelClient) Delete() *AuthIdentityChannelDelete {
mutation := newAuthIdentityChannelMutation(c.config, OpDelete)
return &AuthIdentityChannelDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *AuthIdentityChannelClient) DeleteOne(_m *AuthIdentityChannel) *AuthIdentityChannelDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *AuthIdentityChannelClient) DeleteOneID(id int64) *AuthIdentityChannelDeleteOne {
builder := c.Delete().Where(authidentitychannel.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &AuthIdentityChannelDeleteOne{builder}
}
// Query returns a query builder for AuthIdentityChannel.
func (c *AuthIdentityChannelClient) Query() *AuthIdentityChannelQuery {
return &AuthIdentityChannelQuery{
config: c.config,
ctx: &QueryContext{Type: TypeAuthIdentityChannel},
inters: c.Interceptors(),
}
}
// Get returns a AuthIdentityChannel entity by its id.
func (c *AuthIdentityChannelClient) Get(ctx context.Context, id int64) (*AuthIdentityChannel, error) {
return c.Query().Where(authidentitychannel.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *AuthIdentityChannelClient) GetX(ctx context.Context, id int64) *AuthIdentityChannel {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryIdentity queries the identity edge of a AuthIdentityChannel.
func (c *AuthIdentityChannelClient) QueryIdentity(_m *AuthIdentityChannel) *AuthIdentityQuery {
query := (&AuthIdentityClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(authidentitychannel.Table, authidentitychannel.FieldID, id),
sqlgraph.To(authidentity.Table, authidentity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, authidentitychannel.IdentityTable, authidentitychannel.IdentityColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *AuthIdentityChannelClient) Hooks() []Hook {
return c.hooks.AuthIdentityChannel
}
// Interceptors returns the client interceptors.
func (c *AuthIdentityChannelClient) Interceptors() []Interceptor {
return c.inters.AuthIdentityChannel
}
func (c *AuthIdentityChannelClient) mutate(ctx context.Context, m *AuthIdentityChannelMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&AuthIdentityChannelCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&AuthIdentityChannelUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&AuthIdentityChannelUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&AuthIdentityChannelDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown AuthIdentityChannel mutation op: %q", m.Op())
}
}
// ErrorPassthroughRuleClient is a client for the ErrorPassthroughRule schema.
type ErrorPassthroughRuleClient struct {
config
......@@ -1760,6 +2124,171 @@ func (c *IdempotencyRecordClient) mutate(ctx context.Context, m *IdempotencyReco
}
}
// IdentityAdoptionDecisionClient is a client for the IdentityAdoptionDecision schema.
type IdentityAdoptionDecisionClient struct {
config
}
// NewIdentityAdoptionDecisionClient returns a client for the IdentityAdoptionDecision from the given config.
func NewIdentityAdoptionDecisionClient(c config) *IdentityAdoptionDecisionClient {
return &IdentityAdoptionDecisionClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `identityadoptiondecision.Hooks(f(g(h())))`.
func (c *IdentityAdoptionDecisionClient) Use(hooks ...Hook) {
c.hooks.IdentityAdoptionDecision = append(c.hooks.IdentityAdoptionDecision, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `identityadoptiondecision.Intercept(f(g(h())))`.
func (c *IdentityAdoptionDecisionClient) Intercept(interceptors ...Interceptor) {
c.inters.IdentityAdoptionDecision = append(c.inters.IdentityAdoptionDecision, interceptors...)
}
// Create returns a builder for creating a IdentityAdoptionDecision entity.
func (c *IdentityAdoptionDecisionClient) Create() *IdentityAdoptionDecisionCreate {
mutation := newIdentityAdoptionDecisionMutation(c.config, OpCreate)
return &IdentityAdoptionDecisionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of IdentityAdoptionDecision entities.
func (c *IdentityAdoptionDecisionClient) CreateBulk(builders ...*IdentityAdoptionDecisionCreate) *IdentityAdoptionDecisionCreateBulk {
return &IdentityAdoptionDecisionCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *IdentityAdoptionDecisionClient) MapCreateBulk(slice any, setFunc func(*IdentityAdoptionDecisionCreate, int)) *IdentityAdoptionDecisionCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &IdentityAdoptionDecisionCreateBulk{err: fmt.Errorf("calling to IdentityAdoptionDecisionClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*IdentityAdoptionDecisionCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &IdentityAdoptionDecisionCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for IdentityAdoptionDecision.
func (c *IdentityAdoptionDecisionClient) Update() *IdentityAdoptionDecisionUpdate {
mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdate)
return &IdentityAdoptionDecisionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *IdentityAdoptionDecisionClient) UpdateOne(_m *IdentityAdoptionDecision) *IdentityAdoptionDecisionUpdateOne {
mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdateOne, withIdentityAdoptionDecision(_m))
return &IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *IdentityAdoptionDecisionClient) UpdateOneID(id int64) *IdentityAdoptionDecisionUpdateOne {
mutation := newIdentityAdoptionDecisionMutation(c.config, OpUpdateOne, withIdentityAdoptionDecisionID(id))
return &IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for IdentityAdoptionDecision.
func (c *IdentityAdoptionDecisionClient) Delete() *IdentityAdoptionDecisionDelete {
mutation := newIdentityAdoptionDecisionMutation(c.config, OpDelete)
return &IdentityAdoptionDecisionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *IdentityAdoptionDecisionClient) DeleteOne(_m *IdentityAdoptionDecision) *IdentityAdoptionDecisionDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *IdentityAdoptionDecisionClient) DeleteOneID(id int64) *IdentityAdoptionDecisionDeleteOne {
builder := c.Delete().Where(identityadoptiondecision.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &IdentityAdoptionDecisionDeleteOne{builder}
}
// Query returns a query builder for IdentityAdoptionDecision.
func (c *IdentityAdoptionDecisionClient) Query() *IdentityAdoptionDecisionQuery {
return &IdentityAdoptionDecisionQuery{
config: c.config,
ctx: &QueryContext{Type: TypeIdentityAdoptionDecision},
inters: c.Interceptors(),
}
}
// Get returns a IdentityAdoptionDecision entity by its id.
func (c *IdentityAdoptionDecisionClient) Get(ctx context.Context, id int64) (*IdentityAdoptionDecision, error) {
return c.Query().Where(identityadoptiondecision.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *IdentityAdoptionDecisionClient) GetX(ctx context.Context, id int64) *IdentityAdoptionDecision {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryPendingAuthSession queries the pending_auth_session edge of a IdentityAdoptionDecision.
func (c *IdentityAdoptionDecisionClient) QueryPendingAuthSession(_m *IdentityAdoptionDecision) *PendingAuthSessionQuery {
query := (&PendingAuthSessionClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(identityadoptiondecision.Table, identityadoptiondecision.FieldID, id),
sqlgraph.To(pendingauthsession.Table, pendingauthsession.FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, identityadoptiondecision.PendingAuthSessionTable, identityadoptiondecision.PendingAuthSessionColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryIdentity queries the identity edge of a IdentityAdoptionDecision.
func (c *IdentityAdoptionDecisionClient) QueryIdentity(_m *IdentityAdoptionDecision) *AuthIdentityQuery {
query := (&AuthIdentityClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(identityadoptiondecision.Table, identityadoptiondecision.FieldID, id),
sqlgraph.To(authidentity.Table, authidentity.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, identityadoptiondecision.IdentityTable, identityadoptiondecision.IdentityColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *IdentityAdoptionDecisionClient) Hooks() []Hook {
return c.hooks.IdentityAdoptionDecision
}
// Interceptors returns the client interceptors.
func (c *IdentityAdoptionDecisionClient) Interceptors() []Interceptor {
return c.inters.IdentityAdoptionDecision
}
func (c *IdentityAdoptionDecisionClient) mutate(ctx context.Context, m *IdentityAdoptionDecisionMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&IdentityAdoptionDecisionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&IdentityAdoptionDecisionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&IdentityAdoptionDecisionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&IdentityAdoptionDecisionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown IdentityAdoptionDecision mutation op: %q", m.Op())
}
}
// PaymentAuditLogClient is a client for the PaymentAuditLog schema.
type PaymentAuditLogClient struct {
config
......@@ -2175,6 +2704,171 @@ func (c *PaymentProviderInstanceClient) mutate(ctx context.Context, m *PaymentPr
}
}
// PendingAuthSessionClient is a client for the PendingAuthSession schema.
type PendingAuthSessionClient struct {
config
}
// NewPendingAuthSessionClient returns a client for the PendingAuthSession from the given config.
func NewPendingAuthSessionClient(c config) *PendingAuthSessionClient {
return &PendingAuthSessionClient{config: c}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `pendingauthsession.Hooks(f(g(h())))`.
func (c *PendingAuthSessionClient) Use(hooks ...Hook) {
c.hooks.PendingAuthSession = append(c.hooks.PendingAuthSession, hooks...)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `pendingauthsession.Intercept(f(g(h())))`.
func (c *PendingAuthSessionClient) Intercept(interceptors ...Interceptor) {
c.inters.PendingAuthSession = append(c.inters.PendingAuthSession, interceptors...)
}
// Create returns a builder for creating a PendingAuthSession entity.
func (c *PendingAuthSessionClient) Create() *PendingAuthSessionCreate {
mutation := newPendingAuthSessionMutation(c.config, OpCreate)
return &PendingAuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// CreateBulk returns a builder for creating a bulk of PendingAuthSession entities.
func (c *PendingAuthSessionClient) CreateBulk(builders ...*PendingAuthSessionCreate) *PendingAuthSessionCreateBulk {
return &PendingAuthSessionCreateBulk{config: c.config, builders: builders}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func (c *PendingAuthSessionClient) MapCreateBulk(slice any, setFunc func(*PendingAuthSessionCreate, int)) *PendingAuthSessionCreateBulk {
rv := reflect.ValueOf(slice)
if rv.Kind() != reflect.Slice {
return &PendingAuthSessionCreateBulk{err: fmt.Errorf("calling to PendingAuthSessionClient.MapCreateBulk with wrong type %T, need slice", slice)}
}
builders := make([]*PendingAuthSessionCreate, rv.Len())
for i := 0; i < rv.Len(); i++ {
builders[i] = c.Create()
setFunc(builders[i], i)
}
return &PendingAuthSessionCreateBulk{config: c.config, builders: builders}
}
// Update returns an update builder for PendingAuthSession.
func (c *PendingAuthSessionClient) Update() *PendingAuthSessionUpdate {
mutation := newPendingAuthSessionMutation(c.config, OpUpdate)
return &PendingAuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOne returns an update builder for the given entity.
func (c *PendingAuthSessionClient) UpdateOne(_m *PendingAuthSession) *PendingAuthSessionUpdateOne {
mutation := newPendingAuthSessionMutation(c.config, OpUpdateOne, withPendingAuthSession(_m))
return &PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// UpdateOneID returns an update builder for the given id.
func (c *PendingAuthSessionClient) UpdateOneID(id int64) *PendingAuthSessionUpdateOne {
mutation := newPendingAuthSessionMutation(c.config, OpUpdateOne, withPendingAuthSessionID(id))
return &PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// Delete returns a delete builder for PendingAuthSession.
func (c *PendingAuthSessionClient) Delete() *PendingAuthSessionDelete {
mutation := newPendingAuthSessionMutation(c.config, OpDelete)
return &PendingAuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a builder for deleting the given entity.
func (c *PendingAuthSessionClient) DeleteOne(_m *PendingAuthSession) *PendingAuthSessionDeleteOne {
return c.DeleteOneID(_m.ID)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func (c *PendingAuthSessionClient) DeleteOneID(id int64) *PendingAuthSessionDeleteOne {
builder := c.Delete().Where(pendingauthsession.ID(id))
builder.mutation.id = &id
builder.mutation.op = OpDeleteOne
return &PendingAuthSessionDeleteOne{builder}
}
// Query returns a query builder for PendingAuthSession.
func (c *PendingAuthSessionClient) Query() *PendingAuthSessionQuery {
return &PendingAuthSessionQuery{
config: c.config,
ctx: &QueryContext{Type: TypePendingAuthSession},
inters: c.Interceptors(),
}
}
// Get returns a PendingAuthSession entity by its id.
func (c *PendingAuthSessionClient) Get(ctx context.Context, id int64) (*PendingAuthSession, error) {
return c.Query().Where(pendingauthsession.ID(id)).Only(ctx)
}
// GetX is like Get, but panics if an error occurs.
func (c *PendingAuthSessionClient) GetX(ctx context.Context, id int64) *PendingAuthSession {
obj, err := c.Get(ctx, id)
if err != nil {
panic(err)
}
return obj
}
// QueryTargetUser queries the target_user edge of a PendingAuthSession.
func (c *PendingAuthSessionClient) QueryTargetUser(_m *PendingAuthSession) *UserQuery {
query := (&UserClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(pendingauthsession.Table, pendingauthsession.FieldID, id),
sqlgraph.To(user.Table, user.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, pendingauthsession.TargetUserTable, pendingauthsession.TargetUserColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryAdoptionDecision queries the adoption_decision edge of a PendingAuthSession.
func (c *PendingAuthSessionClient) QueryAdoptionDecision(_m *PendingAuthSession) *IdentityAdoptionDecisionQuery {
query := (&IdentityAdoptionDecisionClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(pendingauthsession.Table, pendingauthsession.FieldID, id),
sqlgraph.To(identityadoptiondecision.Table, identityadoptiondecision.FieldID),
sqlgraph.Edge(sqlgraph.O2O, false, pendingauthsession.AdoptionDecisionTable, pendingauthsession.AdoptionDecisionColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// Hooks returns the client hooks.
func (c *PendingAuthSessionClient) Hooks() []Hook {
return c.hooks.PendingAuthSession
}
// Interceptors returns the client interceptors.
func (c *PendingAuthSessionClient) Interceptors() []Interceptor {
return c.inters.PendingAuthSession
}
func (c *PendingAuthSessionClient) mutate(ctx context.Context, m *PendingAuthSessionMutation) (Value, error) {
switch m.Op() {
case OpCreate:
return (&PendingAuthSessionCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdate:
return (&PendingAuthSessionUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpUpdateOne:
return (&PendingAuthSessionUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
case OpDelete, OpDeleteOne:
return (&PendingAuthSessionDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
default:
return nil, fmt.Errorf("ent: unknown PendingAuthSession mutation op: %q", m.Op())
}
}
// PromoCodeClient is a client for the PromoCode schema.
type PromoCodeClient struct {
config
......@@ -3951,6 +4645,38 @@ func (c *UserClient) QueryPaymentOrders(_m *User) *PaymentOrderQuery {
return query
}
// QueryAuthIdentities queries the auth_identities edge of a User.
func (c *UserClient) QueryAuthIdentities(_m *User) *AuthIdentityQuery {
query := (&AuthIdentityClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(authidentity.Table, authidentity.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, user.AuthIdentitiesTable, user.AuthIdentitiesColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryPendingAuthSessions queries the pending_auth_sessions edge of a User.
func (c *UserClient) QueryPendingAuthSessions(_m *User) *PendingAuthSessionQuery {
query := (&PendingAuthSessionClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := _m.ID
step := sqlgraph.NewStep(
sqlgraph.From(user.Table, user.FieldID, id),
sqlgraph.To(pendingauthsession.Table, pendingauthsession.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, user.PendingAuthSessionsTable, user.PendingAuthSessionsColumn),
)
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
return fromV, nil
}
return query
}
// QueryUserAllowedGroups queries the user_allowed_groups edge of a User.
func (c *UserClient) QueryUserAllowedGroups(_m *User) *UserAllowedGroupQuery {
query := (&UserAllowedGroupClient{config: c.config}).Query()
......@@ -4628,18 +5354,20 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
// hooks and interceptors per client, for fast access.
type (
hooks struct {
APIKey, Account, AccountGroup, Announcement, AnnouncementRead,
ErrorPassthroughRule, Group, IdempotencyRecord, PaymentAuditLog, PaymentOrder,
PaymentProviderInstance, PromoCode, PromoCodeUsage, Proxy, RedeemCode,
SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
AuthIdentityChannel, ErrorPassthroughRule, Group, IdempotencyRecord,
IdentityAdoptionDecision, PaymentAuditLog, PaymentOrder,
PaymentProviderInstance, PendingAuthSession, PromoCode, PromoCodeUsage, Proxy,
RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
UserAttributeValue, UserSubscription []ent.Hook
}
inters struct {
APIKey, Account, AccountGroup, Announcement, AnnouncementRead,
ErrorPassthroughRule, Group, IdempotencyRecord, PaymentAuditLog, PaymentOrder,
PaymentProviderInstance, PromoCode, PromoCodeUsage, Proxy, RedeemCode,
SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
APIKey, Account, AccountGroup, Announcement, AnnouncementRead, AuthIdentity,
AuthIdentityChannel, ErrorPassthroughRule, Group, IdempotencyRecord,
IdentityAdoptionDecision, PaymentAuditLog, PaymentOrder,
PaymentProviderInstance, PendingAuthSession, PromoCode, PromoCodeUsage, Proxy,
RedeemCode, SecuritySecret, Setting, SubscriptionPlan, TLSFingerprintProfile,
UsageCleanupTask, UsageLog, User, UserAllowedGroup, UserAttributeDefinition,
UserAttributeValue, UserSubscription []ent.Interceptor
}
......
......@@ -17,12 +17,16 @@ import (
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/idempotencyrecord"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
"github.com/Wei-Shaw/sub2api/ent/paymentorder"
"github.com/Wei-Shaw/sub2api/ent/paymentproviderinstance"
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/proxy"
......@@ -103,12 +107,16 @@ func checkColumn(t, c string) error {
accountgroup.Table: accountgroup.ValidColumn,
announcement.Table: announcement.ValidColumn,
announcementread.Table: announcementread.ValidColumn,
authidentity.Table: authidentity.ValidColumn,
authidentitychannel.Table: authidentitychannel.ValidColumn,
errorpassthroughrule.Table: errorpassthroughrule.ValidColumn,
group.Table: group.ValidColumn,
idempotencyrecord.Table: idempotencyrecord.ValidColumn,
identityadoptiondecision.Table: identityadoptiondecision.ValidColumn,
paymentauditlog.Table: paymentauditlog.ValidColumn,
paymentorder.Table: paymentorder.ValidColumn,
paymentproviderinstance.Table: paymentproviderinstance.ValidColumn,
pendingauthsession.Table: pendingauthsession.ValidColumn,
promocode.Table: promocode.ValidColumn,
promocodeusage.Table: promocodeusage.ValidColumn,
proxy.Table: proxy.ValidColumn,
......
......@@ -69,6 +69,30 @@ func (f AnnouncementReadFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.V
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AnnouncementReadMutation", m)
}
// The AuthIdentityFunc type is an adapter to allow the use of ordinary
// function as AuthIdentity mutator.
type AuthIdentityFunc func(context.Context, *ent.AuthIdentityMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f AuthIdentityFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.AuthIdentityMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthIdentityMutation", m)
}
// The AuthIdentityChannelFunc type is an adapter to allow the use of ordinary
// function as AuthIdentityChannel mutator.
type AuthIdentityChannelFunc func(context.Context, *ent.AuthIdentityChannelMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f AuthIdentityChannelFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.AuthIdentityChannelMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthIdentityChannelMutation", m)
}
// The ErrorPassthroughRuleFunc type is an adapter to allow the use of ordinary
// function as ErrorPassthroughRule mutator.
type ErrorPassthroughRuleFunc func(context.Context, *ent.ErrorPassthroughRuleMutation) (ent.Value, error)
......@@ -105,6 +129,18 @@ func (f IdempotencyRecordFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.IdempotencyRecordMutation", m)
}
// The IdentityAdoptionDecisionFunc type is an adapter to allow the use of ordinary
// function as IdentityAdoptionDecision mutator.
type IdentityAdoptionDecisionFunc func(context.Context, *ent.IdentityAdoptionDecisionMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f IdentityAdoptionDecisionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.IdentityAdoptionDecisionMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.IdentityAdoptionDecisionMutation", m)
}
// The PaymentAuditLogFunc type is an adapter to allow the use of ordinary
// function as PaymentAuditLog mutator.
type PaymentAuditLogFunc func(context.Context, *ent.PaymentAuditLogMutation) (ent.Value, error)
......@@ -141,6 +177,18 @@ func (f PaymentProviderInstanceFunc) Mutate(ctx context.Context, m ent.Mutation)
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PaymentProviderInstanceMutation", m)
}
// The PendingAuthSessionFunc type is an adapter to allow the use of ordinary
// function as PendingAuthSession mutator.
type PendingAuthSessionFunc func(context.Context, *ent.PendingAuthSessionMutation) (ent.Value, error)
// Mutate calls f(ctx, m).
func (f PendingAuthSessionFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
if mv, ok := m.(*ent.PendingAuthSessionMutation); ok {
return f(ctx, mv)
}
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PendingAuthSessionMutation", m)
}
// The PromoCodeFunc type is an adapter to allow the use of ordinary
// function as PromoCode mutator.
type PromoCodeFunc func(context.Context, *ent.PromoCodeMutation) (ent.Value, error)
......
// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
)
// IdentityAdoptionDecision is the model entity for the IdentityAdoptionDecision schema.
type IdentityAdoptionDecision struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// PendingAuthSessionID holds the value of the "pending_auth_session_id" field.
PendingAuthSessionID int64 `json:"pending_auth_session_id,omitempty"`
// IdentityID holds the value of the "identity_id" field.
IdentityID *int64 `json:"identity_id,omitempty"`
// AdoptDisplayName holds the value of the "adopt_display_name" field.
AdoptDisplayName bool `json:"adopt_display_name,omitempty"`
// AdoptAvatar holds the value of the "adopt_avatar" field.
AdoptAvatar bool `json:"adopt_avatar,omitempty"`
// DecidedAt holds the value of the "decided_at" field.
DecidedAt time.Time `json:"decided_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the IdentityAdoptionDecisionQuery when eager-loading is set.
Edges IdentityAdoptionDecisionEdges `json:"edges"`
selectValues sql.SelectValues
}
// IdentityAdoptionDecisionEdges holds the relations/edges for other nodes in the graph.
type IdentityAdoptionDecisionEdges struct {
// PendingAuthSession holds the value of the pending_auth_session edge.
PendingAuthSession *PendingAuthSession `json:"pending_auth_session,omitempty"`
// Identity holds the value of the identity edge.
Identity *AuthIdentity `json:"identity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// PendingAuthSessionOrErr returns the PendingAuthSession value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e IdentityAdoptionDecisionEdges) PendingAuthSessionOrErr() (*PendingAuthSession, error) {
if e.PendingAuthSession != nil {
return e.PendingAuthSession, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: pendingauthsession.Label}
}
return nil, &NotLoadedError{edge: "pending_auth_session"}
}
// IdentityOrErr returns the Identity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e IdentityAdoptionDecisionEdges) IdentityOrErr() (*AuthIdentity, error) {
if e.Identity != nil {
return e.Identity, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: authidentity.Label}
}
return nil, &NotLoadedError{edge: "identity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*IdentityAdoptionDecision) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case identityadoptiondecision.FieldAdoptDisplayName, identityadoptiondecision.FieldAdoptAvatar:
values[i] = new(sql.NullBool)
case identityadoptiondecision.FieldID, identityadoptiondecision.FieldPendingAuthSessionID, identityadoptiondecision.FieldIdentityID:
values[i] = new(sql.NullInt64)
case identityadoptiondecision.FieldCreatedAt, identityadoptiondecision.FieldUpdatedAt, identityadoptiondecision.FieldDecidedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the IdentityAdoptionDecision fields.
func (_m *IdentityAdoptionDecision) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case identityadoptiondecision.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case identityadoptiondecision.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case identityadoptiondecision.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case identityadoptiondecision.FieldPendingAuthSessionID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field pending_auth_session_id", values[i])
} else if value.Valid {
_m.PendingAuthSessionID = value.Int64
}
case identityadoptiondecision.FieldIdentityID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field identity_id", values[i])
} else if value.Valid {
_m.IdentityID = new(int64)
*_m.IdentityID = value.Int64
}
case identityadoptiondecision.FieldAdoptDisplayName:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field adopt_display_name", values[i])
} else if value.Valid {
_m.AdoptDisplayName = value.Bool
}
case identityadoptiondecision.FieldAdoptAvatar:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field adopt_avatar", values[i])
} else if value.Valid {
_m.AdoptAvatar = value.Bool
}
case identityadoptiondecision.FieldDecidedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field decided_at", values[i])
} else if value.Valid {
_m.DecidedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the IdentityAdoptionDecision.
// This includes values selected through modifiers, order, etc.
func (_m *IdentityAdoptionDecision) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryPendingAuthSession queries the "pending_auth_session" edge of the IdentityAdoptionDecision entity.
func (_m *IdentityAdoptionDecision) QueryPendingAuthSession() *PendingAuthSessionQuery {
return NewIdentityAdoptionDecisionClient(_m.config).QueryPendingAuthSession(_m)
}
// QueryIdentity queries the "identity" edge of the IdentityAdoptionDecision entity.
func (_m *IdentityAdoptionDecision) QueryIdentity() *AuthIdentityQuery {
return NewIdentityAdoptionDecisionClient(_m.config).QueryIdentity(_m)
}
// Update returns a builder for updating this IdentityAdoptionDecision.
// Note that you need to call IdentityAdoptionDecision.Unwrap() before calling this method if this IdentityAdoptionDecision
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *IdentityAdoptionDecision) Update() *IdentityAdoptionDecisionUpdateOne {
return NewIdentityAdoptionDecisionClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the IdentityAdoptionDecision entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (_m *IdentityAdoptionDecision) Unwrap() *IdentityAdoptionDecision {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: IdentityAdoptionDecision is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *IdentityAdoptionDecision) String() string {
var builder strings.Builder
builder.WriteString("IdentityAdoptionDecision(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("pending_auth_session_id=")
builder.WriteString(fmt.Sprintf("%v", _m.PendingAuthSessionID))
builder.WriteString(", ")
if v := _m.IdentityID; v != nil {
builder.WriteString("identity_id=")
builder.WriteString(fmt.Sprintf("%v", *v))
}
builder.WriteString(", ")
builder.WriteString("adopt_display_name=")
builder.WriteString(fmt.Sprintf("%v", _m.AdoptDisplayName))
builder.WriteString(", ")
builder.WriteString("adopt_avatar=")
builder.WriteString(fmt.Sprintf("%v", _m.AdoptAvatar))
builder.WriteString(", ")
builder.WriteString("decided_at=")
builder.WriteString(_m.DecidedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// IdentityAdoptionDecisions is a parsable slice of IdentityAdoptionDecision.
type IdentityAdoptionDecisions []*IdentityAdoptionDecision
// Code generated by ent, DO NOT EDIT.
package identityadoptiondecision
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the identityadoptiondecision type in the database.
Label = "identity_adoption_decision"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// 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"
// FieldPendingAuthSessionID holds the string denoting the pending_auth_session_id field in the database.
FieldPendingAuthSessionID = "pending_auth_session_id"
// FieldIdentityID holds the string denoting the identity_id field in the database.
FieldIdentityID = "identity_id"
// FieldAdoptDisplayName holds the string denoting the adopt_display_name field in the database.
FieldAdoptDisplayName = "adopt_display_name"
// FieldAdoptAvatar holds the string denoting the adopt_avatar field in the database.
FieldAdoptAvatar = "adopt_avatar"
// FieldDecidedAt holds the string denoting the decided_at field in the database.
FieldDecidedAt = "decided_at"
// EdgePendingAuthSession holds the string denoting the pending_auth_session edge name in mutations.
EdgePendingAuthSession = "pending_auth_session"
// EdgeIdentity holds the string denoting the identity edge name in mutations.
EdgeIdentity = "identity"
// Table holds the table name of the identityadoptiondecision in the database.
Table = "identity_adoption_decisions"
// PendingAuthSessionTable is the table that holds the pending_auth_session relation/edge.
PendingAuthSessionTable = "identity_adoption_decisions"
// PendingAuthSessionInverseTable is the table name for the PendingAuthSession entity.
// It exists in this package in order to avoid circular dependency with the "pendingauthsession" package.
PendingAuthSessionInverseTable = "pending_auth_sessions"
// PendingAuthSessionColumn is the table column denoting the pending_auth_session relation/edge.
PendingAuthSessionColumn = "pending_auth_session_id"
// IdentityTable is the table that holds the identity relation/edge.
IdentityTable = "identity_adoption_decisions"
// IdentityInverseTable is the table name for the AuthIdentity entity.
// It exists in this package in order to avoid circular dependency with the "authidentity" package.
IdentityInverseTable = "auth_identities"
// IdentityColumn is the table column denoting the identity relation/edge.
IdentityColumn = "identity_id"
)
// Columns holds all SQL columns for identityadoptiondecision fields.
var Columns = []string{
FieldID,
FieldCreatedAt,
FieldUpdatedAt,
FieldPendingAuthSessionID,
FieldIdentityID,
FieldAdoptDisplayName,
FieldAdoptAvatar,
FieldDecidedAt,
}
// 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 (
// 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
// DefaultAdoptDisplayName holds the default value on creation for the "adopt_display_name" field.
DefaultAdoptDisplayName bool
// DefaultAdoptAvatar holds the default value on creation for the "adopt_avatar" field.
DefaultAdoptAvatar bool
// DefaultDecidedAt holds the default value on creation for the "decided_at" field.
DefaultDecidedAt func() time.Time
)
// OrderOption defines the ordering options for the IdentityAdoptionDecision 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()
}
// 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()
}
// ByPendingAuthSessionID orders the results by the pending_auth_session_id field.
func ByPendingAuthSessionID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPendingAuthSessionID, opts...).ToFunc()
}
// ByIdentityID orders the results by the identity_id field.
func ByIdentityID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldIdentityID, opts...).ToFunc()
}
// ByAdoptDisplayName orders the results by the adopt_display_name field.
func ByAdoptDisplayName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAdoptDisplayName, opts...).ToFunc()
}
// ByAdoptAvatar orders the results by the adopt_avatar field.
func ByAdoptAvatar(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldAdoptAvatar, opts...).ToFunc()
}
// ByDecidedAt orders the results by the decided_at field.
func ByDecidedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDecidedAt, opts...).ToFunc()
}
// ByPendingAuthSessionField orders the results by pending_auth_session field.
func ByPendingAuthSessionField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newPendingAuthSessionStep(), sql.OrderByField(field, opts...))
}
}
// ByIdentityField orders the results by identity field.
func ByIdentityField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newIdentityStep(), sql.OrderByField(field, opts...))
}
}
func newPendingAuthSessionStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(PendingAuthSessionInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, PendingAuthSessionTable, PendingAuthSessionColumn),
)
}
func newIdentityStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(IdentityInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, IdentityTable, IdentityColumn),
)
}
// Code generated by ent, DO NOT EDIT.
package identityadoptiondecision
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func ID(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldID, id))
}
// IDEQ applies the EQ predicate on the ID field.
func IDEQ(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldID, id))
}
// IDNEQ applies the NEQ predicate on the ID field.
func IDNEQ(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldID, id))
}
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldID, ids...))
}
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldID, ids...))
}
// IDGT applies the GT predicate on the ID field.
func IDGT(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGT(FieldID, id))
}
// IDGTE applies the GTE predicate on the ID field.
func IDGTE(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGTE(FieldID, id))
}
// IDLT applies the LT predicate on the ID field.
func IDLT(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLT(FieldID, id))
}
// IDLTE applies the LTE predicate on the ID field.
func IDLTE(id int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLTE(FieldID, id))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func CreatedAt(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(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.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldUpdatedAt, v))
}
// PendingAuthSessionID applies equality check predicate on the "pending_auth_session_id" field. It's identical to PendingAuthSessionIDEQ.
func PendingAuthSessionID(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldPendingAuthSessionID, v))
}
// IdentityID applies equality check predicate on the "identity_id" field. It's identical to IdentityIDEQ.
func IdentityID(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldIdentityID, v))
}
// AdoptDisplayName applies equality check predicate on the "adopt_display_name" field. It's identical to AdoptDisplayNameEQ.
func AdoptDisplayName(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldAdoptDisplayName, v))
}
// AdoptAvatar applies equality check predicate on the "adopt_avatar" field. It's identical to AdoptAvatarEQ.
func AdoptAvatar(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldAdoptAvatar, v))
}
// DecidedAt applies equality check predicate on the "decided_at" field. It's identical to DecidedAtEQ.
func DecidedAt(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldDecidedAt, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func CreatedAtEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldCreatedAt, v))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func CreatedAtNEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldCreatedAt, v))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func CreatedAtIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldCreatedAt, vs...))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func CreatedAtNotIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldCreatedAt, vs...))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func CreatedAtGT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGT(FieldCreatedAt, v))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func CreatedAtGTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGTE(FieldCreatedAt, v))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func CreatedAtLT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLT(FieldCreatedAt, v))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func CreatedAtLTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLTE(FieldCreatedAt, v))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func UpdatedAtEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldUpdatedAt, v))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func UpdatedAtNEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldUpdatedAt, v))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func UpdatedAtIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldUpdatedAt, vs...))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func UpdatedAtNotIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldUpdatedAt, vs...))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func UpdatedAtGT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGT(FieldUpdatedAt, v))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func UpdatedAtGTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGTE(FieldUpdatedAt, v))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func UpdatedAtLT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLT(FieldUpdatedAt, v))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func UpdatedAtLTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLTE(FieldUpdatedAt, v))
}
// PendingAuthSessionIDEQ applies the EQ predicate on the "pending_auth_session_id" field.
func PendingAuthSessionIDEQ(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldPendingAuthSessionID, v))
}
// PendingAuthSessionIDNEQ applies the NEQ predicate on the "pending_auth_session_id" field.
func PendingAuthSessionIDNEQ(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldPendingAuthSessionID, v))
}
// PendingAuthSessionIDIn applies the In predicate on the "pending_auth_session_id" field.
func PendingAuthSessionIDIn(vs ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldPendingAuthSessionID, vs...))
}
// PendingAuthSessionIDNotIn applies the NotIn predicate on the "pending_auth_session_id" field.
func PendingAuthSessionIDNotIn(vs ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldPendingAuthSessionID, vs...))
}
// IdentityIDEQ applies the EQ predicate on the "identity_id" field.
func IdentityIDEQ(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldIdentityID, v))
}
// IdentityIDNEQ applies the NEQ predicate on the "identity_id" field.
func IdentityIDNEQ(v int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldIdentityID, v))
}
// IdentityIDIn applies the In predicate on the "identity_id" field.
func IdentityIDIn(vs ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldIdentityID, vs...))
}
// IdentityIDNotIn applies the NotIn predicate on the "identity_id" field.
func IdentityIDNotIn(vs ...int64) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldIdentityID, vs...))
}
// IdentityIDIsNil applies the IsNil predicate on the "identity_id" field.
func IdentityIDIsNil() predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIsNull(FieldIdentityID))
}
// IdentityIDNotNil applies the NotNil predicate on the "identity_id" field.
func IdentityIDNotNil() predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotNull(FieldIdentityID))
}
// AdoptDisplayNameEQ applies the EQ predicate on the "adopt_display_name" field.
func AdoptDisplayNameEQ(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldAdoptDisplayName, v))
}
// AdoptDisplayNameNEQ applies the NEQ predicate on the "adopt_display_name" field.
func AdoptDisplayNameNEQ(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldAdoptDisplayName, v))
}
// AdoptAvatarEQ applies the EQ predicate on the "adopt_avatar" field.
func AdoptAvatarEQ(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldAdoptAvatar, v))
}
// AdoptAvatarNEQ applies the NEQ predicate on the "adopt_avatar" field.
func AdoptAvatarNEQ(v bool) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldAdoptAvatar, v))
}
// DecidedAtEQ applies the EQ predicate on the "decided_at" field.
func DecidedAtEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldEQ(FieldDecidedAt, v))
}
// DecidedAtNEQ applies the NEQ predicate on the "decided_at" field.
func DecidedAtNEQ(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNEQ(FieldDecidedAt, v))
}
// DecidedAtIn applies the In predicate on the "decided_at" field.
func DecidedAtIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldIn(FieldDecidedAt, vs...))
}
// DecidedAtNotIn applies the NotIn predicate on the "decided_at" field.
func DecidedAtNotIn(vs ...time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldNotIn(FieldDecidedAt, vs...))
}
// DecidedAtGT applies the GT predicate on the "decided_at" field.
func DecidedAtGT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGT(FieldDecidedAt, v))
}
// DecidedAtGTE applies the GTE predicate on the "decided_at" field.
func DecidedAtGTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldGTE(FieldDecidedAt, v))
}
// DecidedAtLT applies the LT predicate on the "decided_at" field.
func DecidedAtLT(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLT(FieldDecidedAt, v))
}
// DecidedAtLTE applies the LTE predicate on the "decided_at" field.
func DecidedAtLTE(v time.Time) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.FieldLTE(FieldDecidedAt, v))
}
// HasPendingAuthSession applies the HasEdge predicate on the "pending_auth_session" edge.
func HasPendingAuthSession() predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.O2O, true, PendingAuthSessionTable, PendingAuthSessionColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasPendingAuthSessionWith applies the HasEdge predicate on the "pending_auth_session" edge with a given conditions (other predicates).
func HasPendingAuthSessionWith(preds ...predicate.PendingAuthSession) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(func(s *sql.Selector) {
step := newPendingAuthSessionStep()
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
for _, p := range preds {
p(s)
}
})
})
}
// HasIdentity applies the HasEdge predicate on the "identity" edge.
func HasIdentity() predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(func(s *sql.Selector) {
step := sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, IdentityTable, IdentityColumn),
)
sqlgraph.HasNeighbors(s, step)
})
}
// HasIdentityWith applies the HasEdge predicate on the "identity" edge with a given conditions (other predicates).
func HasIdentityWith(preds ...predicate.AuthIdentity) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(func(s *sql.Selector) {
step := newIdentityStep()
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.IdentityAdoptionDecision) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.AndPredicates(predicates...))
}
// Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.IdentityAdoptionDecision) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.OrPredicates(predicates...))
}
// Not applies the not operator on the given predicate.
func Not(p predicate.IdentityAdoptionDecision) predicate.IdentityAdoptionDecision {
return predicate.IdentityAdoptionDecision(sql.NotPredicates(p))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment