initial commit
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| .env | ||||
							
								
								
									
										138
									
								
								apiDoc.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										138
									
								
								apiDoc.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,138 @@ | ||||
| Frankenbot API Endpoint | ||||
|  | ||||
| POST [SYS ONLY] /stats/user | ||||
| creates stats for a user inside the stats database | ||||
| { | ||||
| 	serverid, | ||||
| 	userid, | ||||
| 	permtoken, | ||||
| 	created | ||||
| } | ||||
|  | ||||
| PUT [SYS ONLY] /stats/user | ||||
| Updates a Users stats object if present | ||||
| { | ||||
| 	serverid,  | ||||
| 	userid, | ||||
| 	permtoken, | ||||
| 	newxpamount,	 | ||||
| 	newlevelamount, | ||||
| 	newmessageamount | ||||
| } | ||||
|  | ||||
| GET /stats/user | ||||
| fetches a users stats object if present | ||||
| { | ||||
| 	serverid, | ||||
| 	userid, | ||||
| 	permtoken, | ||||
| } | ||||
|  | ||||
| GET /stats/server | ||||
| gets all users registered for a server | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken | ||||
| } | ||||
|  | ||||
| POST [SYS ONLY] /server/settings/general | ||||
| creates settings for a server | ||||
| { | ||||
| 	serverid,  | ||||
| 	permtoken,  | ||||
| 	servername, | ||||
| 	created | ||||
| } | ||||
|  | ||||
| PUT [SYS ONLY] /server/settings/general | ||||
| Updates settings for a specified server | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	logchannel, | ||||
| 	spamchanne,  | ||||
| 	greetingchannel, | ||||
| 	announceChannel, | ||||
| 	logger, | ||||
| 	stats, | ||||
| 	spamprevention, | ||||
| 	worldfilter, | ||||
| 	apitoggle, | ||||
| 	statspage, | ||||
| 	statsmode, | ||||
| 	twitchAnnounce,	 | ||||
| 	twitterAnnounce, | ||||
| 	music, | ||||
| 	moderation | ||||
| } | ||||
|  | ||||
| POST [SYS-WEB ONLY] /server/settings/social | ||||
| adds a new socialmedia account to a server for announcements | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	socialtype, | ||||
| 	identificator | ||||
| } | ||||
|  | ||||
| GET [SYS ONLY] /server/settings/social | ||||
| gets the social media entries of a server | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken | ||||
| } | ||||
|  | ||||
| DELETE [SYS-WEB ONLY] /server/settings/social | ||||
| removes a socialmedia account from a server | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	identificator | ||||
| } | ||||
|  | ||||
| POST [SYS ONLY] /server/settings/filter | ||||
| adds another forbiden word to the servers filter | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	word | ||||
| } | ||||
|  | ||||
| POST [SYSONLY] /server/settings/punishments | ||||
| creates a new automated punishment | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	warnamount, | ||||
| 	punishtype, | ||||
| 	duration, | ||||
| 	reason | ||||
| } | ||||
|  | ||||
| DELETE [SYS ONLY] /server/settings/punishments | ||||
| removes an automated punishment | ||||
| { | ||||
| 	serverid, | ||||
| 	permtoken, | ||||
| 	commiterid, | ||||
| 	warnamounts | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| POST [SYS ONLY] /server/settings/punishments | ||||
| adds a punishment to the database | ||||
| { | ||||
| 	serverid, | ||||
| 	targetid, | ||||
| 	commiterid, | ||||
| 	permtoken, | ||||
| 	type, | ||||
| 	duration, | ||||
| 	reason | ||||
| } | ||||
							
								
								
									
										178
									
								
								ent/actions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								ent/actions.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,178 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| ) | ||||
|  | ||||
| // Actions is the model entity for the Actions schema. | ||||
| type Actions struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Refid holds the value of the "refid" field. | ||||
| 	Refid string `json:"refid,omitempty"` | ||||
| 	// Commiter holds the value of the "commiter" field. | ||||
| 	Commiter string `json:"commiter,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Target holds the value of the "target" field. | ||||
| 	Target string `json:"target,omitempty"` | ||||
| 	// Type holds the value of the "type" field. | ||||
| 	Type string `json:"type,omitempty"` | ||||
| 	// Duration holds the value of the "duration" field. | ||||
| 	Duration string `json:"duration,omitempty"` | ||||
| 	// Reason holds the value of the "reason" field. | ||||
| 	Reason string `json:"reason,omitempty"` | ||||
| 	// Temp holds the value of the "temp" field. | ||||
| 	Temp bool `json:"temp,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Actions) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case actions.FieldTemp: | ||||
| 			values[i] = new(sql.NullBool) | ||||
| 		case actions.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case actions.FieldRefid, actions.FieldCommiter, actions.FieldServerid, actions.FieldTarget, actions.FieldType, actions.FieldDuration, actions.FieldReason: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Actions", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Actions fields. | ||||
| func (a *Actions) assignValues(columns []string, values []interface{}) 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 actions.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			a.ID = int(value.Int64) | ||||
| 		case actions.FieldRefid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field refid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Refid = value.String | ||||
| 			} | ||||
| 		case actions.FieldCommiter: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field commiter", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Commiter = value.String | ||||
| 			} | ||||
| 		case actions.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Serverid = value.String | ||||
| 			} | ||||
| 		case actions.FieldTarget: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field target", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Target = value.String | ||||
| 			} | ||||
| 		case actions.FieldType: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field type", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Type = value.String | ||||
| 			} | ||||
| 		case actions.FieldDuration: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field duration", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Duration = value.String | ||||
| 			} | ||||
| 		case actions.FieldReason: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field reason", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Reason = value.String | ||||
| 			} | ||||
| 		case actions.FieldTemp: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field temp", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Temp = value.Bool | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Actions. | ||||
| // Note that you need to call Actions.Unwrap() before calling this method if this Actions | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (a *Actions) Update() *ActionsUpdateOne { | ||||
| 	return (&ActionsClient{config: a.config}).UpdateOne(a) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Actions 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 (a *Actions) Unwrap() *Actions { | ||||
| 	_tx, ok := a.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Actions is not a transactional entity") | ||||
| 	} | ||||
| 	a.config.driver = _tx.drv | ||||
| 	return a | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (a *Actions) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Actions(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", a.ID)) | ||||
| 	builder.WriteString("refid=") | ||||
| 	builder.WriteString(a.Refid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("commiter=") | ||||
| 	builder.WriteString(a.Commiter) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(a.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("target=") | ||||
| 	builder.WriteString(a.Target) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("type=") | ||||
| 	builder.WriteString(a.Type) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("duration=") | ||||
| 	builder.WriteString(a.Duration) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("reason=") | ||||
| 	builder.WriteString(a.Reason) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("temp=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", a.Temp)) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // ActionsSlice is a parsable slice of Actions. | ||||
| type ActionsSlice []*Actions | ||||
|  | ||||
| func (a ActionsSlice) config(cfg config) { | ||||
| 	for _i := range a { | ||||
| 		a[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										56
									
								
								ent/actions/actions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								ent/actions/actions.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package actions | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the actions type in the database. | ||||
| 	Label = "actions" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldRefid holds the string denoting the refid field in the database. | ||||
| 	FieldRefid = "refid" | ||||
| 	// FieldCommiter holds the string denoting the commiter field in the database. | ||||
| 	FieldCommiter = "commiter" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldTarget holds the string denoting the target field in the database. | ||||
| 	FieldTarget = "target" | ||||
| 	// FieldType holds the string denoting the type field in the database. | ||||
| 	FieldType = "type" | ||||
| 	// FieldDuration holds the string denoting the duration field in the database. | ||||
| 	FieldDuration = "duration" | ||||
| 	// FieldReason holds the string denoting the reason field in the database. | ||||
| 	FieldReason = "reason" | ||||
| 	// FieldTemp holds the string denoting the temp field in the database. | ||||
| 	FieldTemp = "temp" | ||||
| 	// Table holds the table name of the actions in the database. | ||||
| 	Table = "actions" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for actions fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldRefid, | ||||
| 	FieldCommiter, | ||||
| 	FieldServerid, | ||||
| 	FieldTarget, | ||||
| 	FieldType, | ||||
| 	FieldDuration, | ||||
| 	FieldReason, | ||||
| 	FieldTemp, | ||||
| } | ||||
|  | ||||
| // 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 ( | ||||
| 	// DefaultTemp holds the default value on creation for the "temp" field. | ||||
| 	DefaultTemp bool | ||||
| ) | ||||
							
								
								
									
										958
									
								
								ent/actions/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										958
									
								
								ent/actions/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,958 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package actions | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Refid applies equality check predicate on the "refid" field. It's identical to RefidEQ. | ||||
| func Refid(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Commiter applies equality check predicate on the "commiter" field. It's identical to CommiterEQ. | ||||
| func Commiter(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Target applies equality check predicate on the "target" field. It's identical to TargetEQ. | ||||
| func Target(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Type applies equality check predicate on the "type" field. It's identical to TypeEQ. | ||||
| func Type(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Duration applies equality check predicate on the "duration" field. It's identical to DurationEQ. | ||||
| func Duration(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Reason applies equality check predicate on the "reason" field. It's identical to ReasonEQ. | ||||
| func Reason(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Temp applies equality check predicate on the "temp" field. It's identical to TempEQ. | ||||
| func Temp(v bool) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTemp), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEQ applies the EQ predicate on the "refid" field. | ||||
| func RefidEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNEQ applies the NEQ predicate on the "refid" field. | ||||
| func RefidNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidIn applies the In predicate on the "refid" field. | ||||
| func RefidIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNotIn applies the NotIn predicate on the "refid" field. | ||||
| func RefidNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGT applies the GT predicate on the "refid" field. | ||||
| func RefidGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGTE applies the GTE predicate on the "refid" field. | ||||
| func RefidGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLT applies the LT predicate on the "refid" field. | ||||
| func RefidLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLTE applies the LTE predicate on the "refid" field. | ||||
| func RefidLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContains applies the Contains predicate on the "refid" field. | ||||
| func RefidContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasPrefix applies the HasPrefix predicate on the "refid" field. | ||||
| func RefidHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasSuffix applies the HasSuffix predicate on the "refid" field. | ||||
| func RefidHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEqualFold applies the EqualFold predicate on the "refid" field. | ||||
| func RefidEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContainsFold applies the ContainsFold predicate on the "refid" field. | ||||
| func RefidContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterEQ applies the EQ predicate on the "commiter" field. | ||||
| func CommiterEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterNEQ applies the NEQ predicate on the "commiter" field. | ||||
| func CommiterNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterIn applies the In predicate on the "commiter" field. | ||||
| func CommiterIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldCommiter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterNotIn applies the NotIn predicate on the "commiter" field. | ||||
| func CommiterNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldCommiter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterGT applies the GT predicate on the "commiter" field. | ||||
| func CommiterGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterGTE applies the GTE predicate on the "commiter" field. | ||||
| func CommiterGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterLT applies the LT predicate on the "commiter" field. | ||||
| func CommiterLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterLTE applies the LTE predicate on the "commiter" field. | ||||
| func CommiterLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterContains applies the Contains predicate on the "commiter" field. | ||||
| func CommiterContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterHasPrefix applies the HasPrefix predicate on the "commiter" field. | ||||
| func CommiterHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterHasSuffix applies the HasSuffix predicate on the "commiter" field. | ||||
| func CommiterHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterEqualFold applies the EqualFold predicate on the "commiter" field. | ||||
| func CommiterEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterContainsFold applies the ContainsFold predicate on the "commiter" field. | ||||
| func CommiterContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetEQ applies the EQ predicate on the "target" field. | ||||
| func TargetEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetNEQ applies the NEQ predicate on the "target" field. | ||||
| func TargetNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetIn applies the In predicate on the "target" field. | ||||
| func TargetIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldTarget), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetNotIn applies the NotIn predicate on the "target" field. | ||||
| func TargetNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldTarget), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetGT applies the GT predicate on the "target" field. | ||||
| func TargetGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetGTE applies the GTE predicate on the "target" field. | ||||
| func TargetGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetLT applies the LT predicate on the "target" field. | ||||
| func TargetLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetLTE applies the LTE predicate on the "target" field. | ||||
| func TargetLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetContains applies the Contains predicate on the "target" field. | ||||
| func TargetContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetHasPrefix applies the HasPrefix predicate on the "target" field. | ||||
| func TargetHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetHasSuffix applies the HasSuffix predicate on the "target" field. | ||||
| func TargetHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetEqualFold applies the EqualFold predicate on the "target" field. | ||||
| func TargetEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TargetContainsFold applies the ContainsFold predicate on the "target" field. | ||||
| func TargetContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldTarget), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEQ applies the EQ predicate on the "type" field. | ||||
| func TypeEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNEQ applies the NEQ predicate on the "type" field. | ||||
| func TypeNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeIn applies the In predicate on the "type" field. | ||||
| func TypeIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNotIn applies the NotIn predicate on the "type" field. | ||||
| func TypeNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGT applies the GT predicate on the "type" field. | ||||
| func TypeGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGTE applies the GTE predicate on the "type" field. | ||||
| func TypeGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLT applies the LT predicate on the "type" field. | ||||
| func TypeLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLTE applies the LTE predicate on the "type" field. | ||||
| func TypeLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContains applies the Contains predicate on the "type" field. | ||||
| func TypeContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasPrefix applies the HasPrefix predicate on the "type" field. | ||||
| func TypeHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasSuffix applies the HasSuffix predicate on the "type" field. | ||||
| func TypeHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEqualFold applies the EqualFold predicate on the "type" field. | ||||
| func TypeEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContainsFold applies the ContainsFold predicate on the "type" field. | ||||
| func TypeContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationEQ applies the EQ predicate on the "duration" field. | ||||
| func DurationEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationNEQ applies the NEQ predicate on the "duration" field. | ||||
| func DurationNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationIn applies the In predicate on the "duration" field. | ||||
| func DurationIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldDuration), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationNotIn applies the NotIn predicate on the "duration" field. | ||||
| func DurationNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldDuration), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationGT applies the GT predicate on the "duration" field. | ||||
| func DurationGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationGTE applies the GTE predicate on the "duration" field. | ||||
| func DurationGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationLT applies the LT predicate on the "duration" field. | ||||
| func DurationLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationLTE applies the LTE predicate on the "duration" field. | ||||
| func DurationLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationContains applies the Contains predicate on the "duration" field. | ||||
| func DurationContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationHasPrefix applies the HasPrefix predicate on the "duration" field. | ||||
| func DurationHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationHasSuffix applies the HasSuffix predicate on the "duration" field. | ||||
| func DurationHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationEqualFold applies the EqualFold predicate on the "duration" field. | ||||
| func DurationEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationContainsFold applies the ContainsFold predicate on the "duration" field. | ||||
| func DurationContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonEQ applies the EQ predicate on the "reason" field. | ||||
| func ReasonEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonNEQ applies the NEQ predicate on the "reason" field. | ||||
| func ReasonNEQ(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonIn applies the In predicate on the "reason" field. | ||||
| func ReasonIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldReason), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonNotIn applies the NotIn predicate on the "reason" field. | ||||
| func ReasonNotIn(vs ...string) predicate.Actions { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldReason), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonGT applies the GT predicate on the "reason" field. | ||||
| func ReasonGT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonGTE applies the GTE predicate on the "reason" field. | ||||
| func ReasonGTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonLT applies the LT predicate on the "reason" field. | ||||
| func ReasonLT(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonLTE applies the LTE predicate on the "reason" field. | ||||
| func ReasonLTE(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonContains applies the Contains predicate on the "reason" field. | ||||
| func ReasonContains(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonHasPrefix applies the HasPrefix predicate on the "reason" field. | ||||
| func ReasonHasPrefix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonHasSuffix applies the HasSuffix predicate on the "reason" field. | ||||
| func ReasonHasSuffix(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonEqualFold applies the EqualFold predicate on the "reason" field. | ||||
| func ReasonEqualFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonContainsFold applies the ContainsFold predicate on the "reason" field. | ||||
| func ReasonContainsFold(v string) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TempEQ applies the EQ predicate on the "temp" field. | ||||
| func TempEQ(v bool) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTemp), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TempNEQ applies the NEQ predicate on the "temp" field. | ||||
| func TempNEQ(v bool) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldTemp), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Actions) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Actions) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Actions) predicate.Actions { | ||||
| 	return predicate.Actions(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										375
									
								
								ent/actions_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										375
									
								
								ent/actions_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,375 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| ) | ||||
|  | ||||
| // ActionsCreate is the builder for creating a Actions entity. | ||||
| type ActionsCreate struct { | ||||
| 	config | ||||
| 	mutation *ActionsMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (ac *ActionsCreate) SetRefid(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetRefid(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (ac *ActionsCreate) SetCommiter(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetCommiter(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (ac *ActionsCreate) SetServerid(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetServerid(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetTarget sets the "target" field. | ||||
| func (ac *ActionsCreate) SetTarget(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetTarget(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (ac *ActionsCreate) SetType(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetType(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (ac *ActionsCreate) SetDuration(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetDuration(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (ac *ActionsCreate) SetReason(s string) *ActionsCreate { | ||||
| 	ac.mutation.SetReason(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetTemp sets the "temp" field. | ||||
| func (ac *ActionsCreate) SetTemp(b bool) *ActionsCreate { | ||||
| 	ac.mutation.SetTemp(b) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetNillableTemp sets the "temp" field if the given value is not nil. | ||||
| func (ac *ActionsCreate) SetNillableTemp(b *bool) *ActionsCreate { | ||||
| 	if b != nil { | ||||
| 		ac.SetTemp(*b) | ||||
| 	} | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (ac *ActionsCreate) SetID(i int) *ActionsCreate { | ||||
| 	ac.mutation.SetID(i) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // Mutation returns the ActionsMutation object of the builder. | ||||
| func (ac *ActionsCreate) Mutation() *ActionsMutation { | ||||
| 	return ac.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Actions in the database. | ||||
| func (ac *ActionsCreate) Save(ctx context.Context) (*Actions, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Actions | ||||
| 	) | ||||
| 	ac.defaults() | ||||
| 	if len(ac.hooks) == 0 { | ||||
| 		if err = ac.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = ac.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ActionsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = ac.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ac.mutation = mutation | ||||
| 			if node, err = ac.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(ac.hooks) - 1; i >= 0; i-- { | ||||
| 			if ac.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = ac.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, ac.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Actions) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from ActionsMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (ac *ActionsCreate) SaveX(ctx context.Context) *Actions { | ||||
| 	v, err := ac.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (ac *ActionsCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := ac.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ac *ActionsCreate) ExecX(ctx context.Context) { | ||||
| 	if err := ac.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // defaults sets the default values of the builder before save. | ||||
| func (ac *ActionsCreate) defaults() { | ||||
| 	if _, ok := ac.mutation.Temp(); !ok { | ||||
| 		v := actions.DefaultTemp | ||||
| 		ac.mutation.SetTemp(v) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (ac *ActionsCreate) check() error { | ||||
| 	if _, ok := ac.mutation.Refid(); !ok { | ||||
| 		return &ValidationError{Name: "refid", err: errors.New(`ent: missing required field "Actions.refid"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Commiter(); !ok { | ||||
| 		return &ValidationError{Name: "commiter", err: errors.New(`ent: missing required field "Actions.commiter"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Actions.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Target(); !ok { | ||||
| 		return &ValidationError{Name: "target", err: errors.New(`ent: missing required field "Actions.target"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.GetType(); !ok { | ||||
| 		return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Actions.type"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Duration(); !ok { | ||||
| 		return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Actions.duration"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Reason(); !ok { | ||||
| 		return &ValidationError{Name: "reason", err: errors.New(`ent: missing required field "Actions.reason"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Temp(); !ok { | ||||
| 		return &ValidationError{Name: "temp", err: errors.New(`ent: missing required field "Actions.temp"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (ac *ActionsCreate) sqlSave(ctx context.Context) (*Actions, error) { | ||||
| 	_node, _spec := ac.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (ac *ActionsCreate) createSpec() (*Actions, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Actions{config: ac.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: actions.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: actions.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := ac.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Refid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldRefid, | ||||
| 		}) | ||||
| 		_node.Refid = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Commiter(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldCommiter, | ||||
| 		}) | ||||
| 		_node.Commiter = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Target(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTarget, | ||||
| 		}) | ||||
| 		_node.Target = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.GetType(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldType, | ||||
| 		}) | ||||
| 		_node.Type = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Duration(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldDuration, | ||||
| 		}) | ||||
| 		_node.Duration = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Reason(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldReason, | ||||
| 		}) | ||||
| 		_node.Reason = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Temp(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTemp, | ||||
| 		}) | ||||
| 		_node.Temp = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // ActionsCreateBulk is the builder for creating many Actions entities in bulk. | ||||
| type ActionsCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*ActionsCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Actions entities in the database. | ||||
| func (acb *ActionsCreateBulk) Save(ctx context.Context) ([]*Actions, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) | ||||
| 	nodes := make([]*Actions, len(acb.builders)) | ||||
| 	mutators := make([]Mutator, len(acb.builders)) | ||||
| 	for i := range acb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := acb.builders[i] | ||||
| 			builder.defaults() | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*ActionsMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, acb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, acb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, acb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (acb *ActionsCreateBulk) SaveX(ctx context.Context) []*Actions { | ||||
| 	v, err := acb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (acb *ActionsCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := acb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (acb *ActionsCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := acb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/actions_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/actions_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ActionsDelete is the builder for deleting a Actions entity. | ||||
| type ActionsDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *ActionsMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the ActionsDelete builder. | ||||
| func (ad *ActionsDelete) Where(ps ...predicate.Actions) *ActionsDelete { | ||||
| 	ad.mutation.Where(ps...) | ||||
| 	return ad | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (ad *ActionsDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(ad.hooks) == 0 { | ||||
| 		affected, err = ad.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ActionsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			ad.mutation = mutation | ||||
| 			affected, err = ad.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(ad.hooks) - 1; i >= 0; i-- { | ||||
| 			if ad.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = ad.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, ad.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ad *ActionsDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := ad.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (ad *ActionsDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: actions.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: actions.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := ad.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ActionsDeleteOne is the builder for deleting a single Actions entity. | ||||
| type ActionsDeleteOne struct { | ||||
| 	ad *ActionsDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (ado *ActionsDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := ado.ad.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{actions.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ado *ActionsDeleteOne) ExecX(ctx context.Context) { | ||||
| 	ado.ad.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/actions_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/actions_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ActionsQuery is the builder for querying Actions entities. | ||||
| type ActionsQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Actions | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the ActionsQuery builder. | ||||
| func (aq *ActionsQuery) Where(ps ...predicate.Actions) *ActionsQuery { | ||||
| 	aq.predicates = append(aq.predicates, ps...) | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (aq *ActionsQuery) Limit(limit int) *ActionsQuery { | ||||
| 	aq.limit = &limit | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (aq *ActionsQuery) Offset(offset int) *ActionsQuery { | ||||
| 	aq.offset = &offset | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // 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 (aq *ActionsQuery) Unique(unique bool) *ActionsQuery { | ||||
| 	aq.unique = &unique | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (aq *ActionsQuery) Order(o ...OrderFunc) *ActionsQuery { | ||||
| 	aq.order = append(aq.order, o...) | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // First returns the first Actions entity from the query. | ||||
| // Returns a *NotFoundError when no Actions was found. | ||||
| func (aq *ActionsQuery) First(ctx context.Context) (*Actions, error) { | ||||
| 	nodes, err := aq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{actions.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) FirstX(ctx context.Context) *Actions { | ||||
| 	node, err := aq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Actions ID from the query. | ||||
| // Returns a *NotFoundError when no Actions ID was found. | ||||
| func (aq *ActionsQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = aq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{actions.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := aq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Actions entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Actions entity is found. | ||||
| // Returns a *NotFoundError when no Actions entities are found. | ||||
| func (aq *ActionsQuery) Only(ctx context.Context) (*Actions, error) { | ||||
| 	nodes, err := aq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{actions.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{actions.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) OnlyX(ctx context.Context) *Actions { | ||||
| 	node, err := aq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Actions ID in the query. | ||||
| // Returns a *NotSingularError when more than one Actions ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (aq *ActionsQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = aq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{actions.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{actions.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := aq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of ActionsSlice. | ||||
| func (aq *ActionsQuery) All(ctx context.Context) ([]*Actions, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return aq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) AllX(ctx context.Context) []*Actions { | ||||
| 	nodes, err := aq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Actions IDs. | ||||
| func (aq *ActionsQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := aq.Select(actions.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := aq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (aq *ActionsQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return aq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := aq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (aq *ActionsQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return aq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (aq *ActionsQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := aq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the ActionsQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (aq *ActionsQuery) Clone() *ActionsQuery { | ||||
| 	if aq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &ActionsQuery{ | ||||
| 		config:     aq.config, | ||||
| 		limit:      aq.limit, | ||||
| 		offset:     aq.offset, | ||||
| 		order:      append([]OrderFunc{}, aq.order...), | ||||
| 		predicates: append([]predicate.Actions{}, aq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    aq.sql.Clone(), | ||||
| 		path:   aq.path, | ||||
| 		unique: aq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Actions.Query(). | ||||
| //		GroupBy(actions.FieldRefid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (aq *ActionsQuery) GroupBy(field string, fields ...string) *ActionsGroupBy { | ||||
| 	grbuild := &ActionsGroupBy{config: aq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := aq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return aq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = actions.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Actions.Query(). | ||||
| //		Select(actions.FieldRefid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (aq *ActionsQuery) Select(fields ...string) *ActionsSelect { | ||||
| 	aq.fields = append(aq.fields, fields...) | ||||
| 	selbuild := &ActionsSelect{ActionsQuery: aq} | ||||
| 	selbuild.label = actions.Label | ||||
| 	selbuild.flds, selbuild.scan = &aq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range aq.fields { | ||||
| 		if !actions.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if aq.path != nil { | ||||
| 		prev, err := aq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		aq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Actions, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Actions{} | ||||
| 		_spec = aq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Actions).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Actions{config: aq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := aq.querySpec() | ||||
| 	_spec.Node.Columns = aq.fields | ||||
| 	if len(aq.fields) > 0 { | ||||
| 		_spec.Unique = aq.unique != nil && *aq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, aq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := aq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   actions.Table, | ||||
| 			Columns: actions.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: actions.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   aq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := aq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := aq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, actions.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != actions.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := aq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := aq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := aq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := aq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (aq *ActionsQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(aq.driver.Dialect()) | ||||
| 	t1 := builder.Table(actions.Table) | ||||
| 	columns := aq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = actions.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if aq.sql != nil { | ||||
| 		selector = aq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if aq.unique != nil && *aq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range aq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range aq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := aq.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 := aq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // ActionsGroupBy is the group-by builder for Actions entities. | ||||
| type ActionsGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (agb *ActionsGroupBy) Aggregate(fns ...AggregateFunc) *ActionsGroupBy { | ||||
| 	agb.fns = append(agb.fns, fns...) | ||||
| 	return agb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (agb *ActionsGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := agb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	agb.sql = query | ||||
| 	return agb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (agb *ActionsGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range agb.fields { | ||||
| 		if !actions.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := agb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := agb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (agb *ActionsGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := agb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(agb.fns)) | ||||
| 	for _, fn := range agb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(agb.fields)+len(agb.fns)) | ||||
| 		for _, f := range agb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(agb.fields...)...) | ||||
| } | ||||
|  | ||||
| // ActionsSelect is the builder for selecting fields of Actions entities. | ||||
| type ActionsSelect struct { | ||||
| 	*ActionsQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (as *ActionsSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := as.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	as.sql = as.ActionsQuery.sqlQuery(ctx) | ||||
| 	return as.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (as *ActionsSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := as.sql.Query() | ||||
| 	if err := as.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										469
									
								
								ent/actions_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										469
									
								
								ent/actions_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,469 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ActionsUpdate is the builder for updating Actions entities. | ||||
| type ActionsUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *ActionsMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the ActionsUpdate builder. | ||||
| func (au *ActionsUpdate) Where(ps ...predicate.Actions) *ActionsUpdate { | ||||
| 	au.mutation.Where(ps...) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (au *ActionsUpdate) SetRefid(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetRefid(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (au *ActionsUpdate) SetCommiter(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetCommiter(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (au *ActionsUpdate) SetServerid(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetServerid(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetTarget sets the "target" field. | ||||
| func (au *ActionsUpdate) SetTarget(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetTarget(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (au *ActionsUpdate) SetType(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetType(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (au *ActionsUpdate) SetDuration(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetDuration(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (au *ActionsUpdate) SetReason(s string) *ActionsUpdate { | ||||
| 	au.mutation.SetReason(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetTemp sets the "temp" field. | ||||
| func (au *ActionsUpdate) SetTemp(b bool) *ActionsUpdate { | ||||
| 	au.mutation.SetTemp(b) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetNillableTemp sets the "temp" field if the given value is not nil. | ||||
| func (au *ActionsUpdate) SetNillableTemp(b *bool) *ActionsUpdate { | ||||
| 	if b != nil { | ||||
| 		au.SetTemp(*b) | ||||
| 	} | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // Mutation returns the ActionsMutation object of the builder. | ||||
| func (au *ActionsUpdate) Mutation() *ActionsMutation { | ||||
| 	return au.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (au *ActionsUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(au.hooks) == 0 { | ||||
| 		affected, err = au.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ActionsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			au.mutation = mutation | ||||
| 			affected, err = au.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(au.hooks) - 1; i >= 0; i-- { | ||||
| 			if au.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = au.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, au.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (au *ActionsUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := au.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (au *ActionsUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := au.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (au *ActionsUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := au.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (au *ActionsUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   actions.Table, | ||||
| 			Columns: actions.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: actions.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := au.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Commiter(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldCommiter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Target(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTarget, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Duration(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldDuration, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Reason(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldReason, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Temp(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTemp, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{actions.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // ActionsUpdateOne is the builder for updating a single Actions entity. | ||||
| type ActionsUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *ActionsMutation | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (auo *ActionsUpdateOne) SetRefid(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetRefid(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (auo *ActionsUpdateOne) SetCommiter(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetCommiter(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (auo *ActionsUpdateOne) SetServerid(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetServerid(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetTarget sets the "target" field. | ||||
| func (auo *ActionsUpdateOne) SetTarget(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetTarget(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (auo *ActionsUpdateOne) SetType(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetType(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (auo *ActionsUpdateOne) SetDuration(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetDuration(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (auo *ActionsUpdateOne) SetReason(s string) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetReason(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetTemp sets the "temp" field. | ||||
| func (auo *ActionsUpdateOne) SetTemp(b bool) *ActionsUpdateOne { | ||||
| 	auo.mutation.SetTemp(b) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetNillableTemp sets the "temp" field if the given value is not nil. | ||||
| func (auo *ActionsUpdateOne) SetNillableTemp(b *bool) *ActionsUpdateOne { | ||||
| 	if b != nil { | ||||
| 		auo.SetTemp(*b) | ||||
| 	} | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // Mutation returns the ActionsMutation object of the builder. | ||||
| func (auo *ActionsUpdateOne) Mutation() *ActionsMutation { | ||||
| 	return auo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (auo *ActionsUpdateOne) Select(field string, fields ...string) *ActionsUpdateOne { | ||||
| 	auo.fields = append([]string{field}, fields...) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Actions entity. | ||||
| func (auo *ActionsUpdateOne) Save(ctx context.Context) (*Actions, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Actions | ||||
| 	) | ||||
| 	if len(auo.hooks) == 0 { | ||||
| 		node, err = auo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ActionsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			auo.mutation = mutation | ||||
| 			node, err = auo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(auo.hooks) - 1; i >= 0; i-- { | ||||
| 			if auo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = auo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, auo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Actions) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from ActionsMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (auo *ActionsUpdateOne) SaveX(ctx context.Context) *Actions { | ||||
| 	node, err := auo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (auo *ActionsUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := auo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (auo *ActionsUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := auo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (auo *ActionsUpdateOne) sqlSave(ctx context.Context) (_node *Actions, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   actions.Table, | ||||
| 			Columns: actions.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: actions.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := auo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Actions.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := auo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, actions.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !actions.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != actions.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := auo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Commiter(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldCommiter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Target(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTarget, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Duration(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldDuration, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Reason(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldReason, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Temp(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: actions.FieldTemp, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Actions{config: auo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{actions.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										132
									
								
								ent/authorizables.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								ent/authorizables.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,132 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| ) | ||||
|  | ||||
| // Authorizables is the model entity for the Authorizables schema. | ||||
| type Authorizables struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Username holds the value of the "username" field. | ||||
| 	Username string `json:"username,omitempty"` | ||||
| 	// Password holds the value of the "password" field. | ||||
| 	Password string `json:"password,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Userid holds the value of the "userid" field. | ||||
| 	Userid string `json:"userid,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Authorizables) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case authorizables.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case authorizables.FieldUsername, authorizables.FieldPassword, authorizables.FieldServerid, authorizables.FieldUserid: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Authorizables", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Authorizables fields. | ||||
| func (a *Authorizables) assignValues(columns []string, values []interface{}) 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 authorizables.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			a.ID = int(value.Int64) | ||||
| 		case authorizables.FieldUsername: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field username", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Username = value.String | ||||
| 			} | ||||
| 		case authorizables.FieldPassword: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field password", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Password = value.String | ||||
| 			} | ||||
| 		case authorizables.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Serverid = value.String | ||||
| 			} | ||||
| 		case authorizables.FieldUserid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field userid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				a.Userid = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Authorizables. | ||||
| // Note that you need to call Authorizables.Unwrap() before calling this method if this Authorizables | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (a *Authorizables) Update() *AuthorizablesUpdateOne { | ||||
| 	return (&AuthorizablesClient{config: a.config}).UpdateOne(a) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Authorizables 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 (a *Authorizables) Unwrap() *Authorizables { | ||||
| 	_tx, ok := a.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Authorizables is not a transactional entity") | ||||
| 	} | ||||
| 	a.config.driver = _tx.drv | ||||
| 	return a | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (a *Authorizables) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Authorizables(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", a.ID)) | ||||
| 	builder.WriteString("username=") | ||||
| 	builder.WriteString(a.Username) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("password=") | ||||
| 	builder.WriteString(a.Password) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(a.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("userid=") | ||||
| 	builder.WriteString(a.Userid) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // AuthorizablesSlice is a parsable slice of Authorizables. | ||||
| type AuthorizablesSlice []*Authorizables | ||||
|  | ||||
| func (a AuthorizablesSlice) config(cfg config) { | ||||
| 	for _i := range a { | ||||
| 		a[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										39
									
								
								ent/authorizables/authorizables.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ent/authorizables/authorizables.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package authorizables | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the authorizables type in the database. | ||||
| 	Label = "authorizables" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldUsername holds the string denoting the username field in the database. | ||||
| 	FieldUsername = "username" | ||||
| 	// FieldPassword holds the string denoting the password field in the database. | ||||
| 	FieldPassword = "password" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldUserid holds the string denoting the userid field in the database. | ||||
| 	FieldUserid = "userid" | ||||
| 	// Table holds the table name of the authorizables in the database. | ||||
| 	Table = "authorizables" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for authorizables fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldUsername, | ||||
| 	FieldPassword, | ||||
| 	FieldServerid, | ||||
| 	FieldUserid, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										583
									
								
								ent/authorizables/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										583
									
								
								ent/authorizables/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,583 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package authorizables | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. | ||||
| func Username(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Password applies equality check predicate on the "password" field. It's identical to PasswordEQ. | ||||
| func Password(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Userid applies equality check predicate on the "userid" field. It's identical to UseridEQ. | ||||
| func Userid(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameEQ applies the EQ predicate on the "username" field. | ||||
| func UsernameEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameNEQ applies the NEQ predicate on the "username" field. | ||||
| func UsernameNEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameIn applies the In predicate on the "username" field. | ||||
| func UsernameIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldUsername), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameNotIn applies the NotIn predicate on the "username" field. | ||||
| func UsernameNotIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldUsername), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameGT applies the GT predicate on the "username" field. | ||||
| func UsernameGT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameGTE applies the GTE predicate on the "username" field. | ||||
| func UsernameGTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameLT applies the LT predicate on the "username" field. | ||||
| func UsernameLT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameLTE applies the LTE predicate on the "username" field. | ||||
| func UsernameLTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameContains applies the Contains predicate on the "username" field. | ||||
| func UsernameContains(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameHasPrefix applies the HasPrefix predicate on the "username" field. | ||||
| func UsernameHasPrefix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameHasSuffix applies the HasSuffix predicate on the "username" field. | ||||
| func UsernameHasSuffix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameEqualFold applies the EqualFold predicate on the "username" field. | ||||
| func UsernameEqualFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UsernameContainsFold applies the ContainsFold predicate on the "username" field. | ||||
| func UsernameContainsFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldUsername), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordEQ applies the EQ predicate on the "password" field. | ||||
| func PasswordEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordNEQ applies the NEQ predicate on the "password" field. | ||||
| func PasswordNEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordIn applies the In predicate on the "password" field. | ||||
| func PasswordIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldPassword), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordNotIn applies the NotIn predicate on the "password" field. | ||||
| func PasswordNotIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldPassword), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordGT applies the GT predicate on the "password" field. | ||||
| func PasswordGT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordGTE applies the GTE predicate on the "password" field. | ||||
| func PasswordGTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordLT applies the LT predicate on the "password" field. | ||||
| func PasswordLT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordLTE applies the LTE predicate on the "password" field. | ||||
| func PasswordLTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordContains applies the Contains predicate on the "password" field. | ||||
| func PasswordContains(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordHasPrefix applies the HasPrefix predicate on the "password" field. | ||||
| func PasswordHasPrefix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordHasSuffix applies the HasSuffix predicate on the "password" field. | ||||
| func PasswordHasSuffix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordEqualFold applies the EqualFold predicate on the "password" field. | ||||
| func PasswordEqualFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PasswordContainsFold applies the ContainsFold predicate on the "password" field. | ||||
| func PasswordContainsFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldPassword), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridEQ applies the EQ predicate on the "userid" field. | ||||
| func UseridEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridNEQ applies the NEQ predicate on the "userid" field. | ||||
| func UseridNEQ(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridIn applies the In predicate on the "userid" field. | ||||
| func UseridIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldUserid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridNotIn applies the NotIn predicate on the "userid" field. | ||||
| func UseridNotIn(vs ...string) predicate.Authorizables { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldUserid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridGT applies the GT predicate on the "userid" field. | ||||
| func UseridGT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridGTE applies the GTE predicate on the "userid" field. | ||||
| func UseridGTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridLT applies the LT predicate on the "userid" field. | ||||
| func UseridLT(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridLTE applies the LTE predicate on the "userid" field. | ||||
| func UseridLTE(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridContains applies the Contains predicate on the "userid" field. | ||||
| func UseridContains(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridHasPrefix applies the HasPrefix predicate on the "userid" field. | ||||
| func UseridHasPrefix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridHasSuffix applies the HasSuffix predicate on the "userid" field. | ||||
| func UseridHasSuffix(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridEqualFold applies the EqualFold predicate on the "userid" field. | ||||
| func UseridEqualFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridContainsFold applies the ContainsFold predicate on the "userid" field. | ||||
| func UseridContainsFold(v string) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Authorizables) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Authorizables) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Authorizables) predicate.Authorizables { | ||||
| 	return predicate.Authorizables(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										277
									
								
								ent/authorizables_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										277
									
								
								ent/authorizables_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,277 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| ) | ||||
|  | ||||
| // AuthorizablesCreate is the builder for creating a Authorizables entity. | ||||
| type AuthorizablesCreate struct { | ||||
| 	config | ||||
| 	mutation *AuthorizablesMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetUsername sets the "username" field. | ||||
| func (ac *AuthorizablesCreate) SetUsername(s string) *AuthorizablesCreate { | ||||
| 	ac.mutation.SetUsername(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetPassword sets the "password" field. | ||||
| func (ac *AuthorizablesCreate) SetPassword(s string) *AuthorizablesCreate { | ||||
| 	ac.mutation.SetPassword(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (ac *AuthorizablesCreate) SetServerid(s string) *AuthorizablesCreate { | ||||
| 	ac.mutation.SetServerid(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (ac *AuthorizablesCreate) SetUserid(s string) *AuthorizablesCreate { | ||||
| 	ac.mutation.SetUserid(s) | ||||
| 	return ac | ||||
| } | ||||
|  | ||||
| // Mutation returns the AuthorizablesMutation object of the builder. | ||||
| func (ac *AuthorizablesCreate) Mutation() *AuthorizablesMutation { | ||||
| 	return ac.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Authorizables in the database. | ||||
| func (ac *AuthorizablesCreate) Save(ctx context.Context) (*Authorizables, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Authorizables | ||||
| 	) | ||||
| 	if len(ac.hooks) == 0 { | ||||
| 		if err = ac.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = ac.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*AuthorizablesMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = ac.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			ac.mutation = mutation | ||||
| 			if node, err = ac.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(ac.hooks) - 1; i >= 0; i-- { | ||||
| 			if ac.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = ac.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, ac.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Authorizables) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from AuthorizablesMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (ac *AuthorizablesCreate) SaveX(ctx context.Context) *Authorizables { | ||||
| 	v, err := ac.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (ac *AuthorizablesCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := ac.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ac *AuthorizablesCreate) ExecX(ctx context.Context) { | ||||
| 	if err := ac.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (ac *AuthorizablesCreate) check() error { | ||||
| 	if _, ok := ac.mutation.Username(); !ok { | ||||
| 		return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "Authorizables.username"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Password(); !ok { | ||||
| 		return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "Authorizables.password"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Authorizables.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := ac.mutation.Userid(); !ok { | ||||
| 		return &ValidationError{Name: "userid", err: errors.New(`ent: missing required field "Authorizables.userid"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (ac *AuthorizablesCreate) sqlSave(ctx context.Context) (*Authorizables, error) { | ||||
| 	_node, _spec := ac.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, ac.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 = int(id) | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (ac *AuthorizablesCreate) createSpec() (*Authorizables, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Authorizables{config: ac.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: authorizables.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: authorizables.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if value, ok := ac.mutation.Username(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUsername, | ||||
| 		}) | ||||
| 		_node.Username = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Password(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldPassword, | ||||
| 		}) | ||||
| 		_node.Password = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := ac.mutation.Userid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUserid, | ||||
| 		}) | ||||
| 		_node.Userid = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // AuthorizablesCreateBulk is the builder for creating many Authorizables entities in bulk. | ||||
| type AuthorizablesCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*AuthorizablesCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Authorizables entities in the database. | ||||
| func (acb *AuthorizablesCreateBulk) Save(ctx context.Context) ([]*Authorizables, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(acb.builders)) | ||||
| 	nodes := make([]*Authorizables, len(acb.builders)) | ||||
| 	mutators := make([]Mutator, len(acb.builders)) | ||||
| 	for i := range acb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := acb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*AuthorizablesMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, acb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, acb.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 = int(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, acb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (acb *AuthorizablesCreateBulk) SaveX(ctx context.Context) []*Authorizables { | ||||
| 	v, err := acb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (acb *AuthorizablesCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := acb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (acb *AuthorizablesCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := acb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/authorizables_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/authorizables_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // AuthorizablesDelete is the builder for deleting a Authorizables entity. | ||||
| type AuthorizablesDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *AuthorizablesMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the AuthorizablesDelete builder. | ||||
| func (ad *AuthorizablesDelete) Where(ps ...predicate.Authorizables) *AuthorizablesDelete { | ||||
| 	ad.mutation.Where(ps...) | ||||
| 	return ad | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (ad *AuthorizablesDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(ad.hooks) == 0 { | ||||
| 		affected, err = ad.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*AuthorizablesMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			ad.mutation = mutation | ||||
| 			affected, err = ad.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(ad.hooks) - 1; i >= 0; i-- { | ||||
| 			if ad.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = ad.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, ad.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ad *AuthorizablesDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := ad.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (ad *AuthorizablesDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: authorizables.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: authorizables.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := ad.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // AuthorizablesDeleteOne is the builder for deleting a single Authorizables entity. | ||||
| type AuthorizablesDeleteOne struct { | ||||
| 	ad *AuthorizablesDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (ado *AuthorizablesDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := ado.ad.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{authorizables.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ado *AuthorizablesDeleteOne) ExecX(ctx context.Context) { | ||||
| 	ado.ad.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/authorizables_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/authorizables_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // AuthorizablesQuery is the builder for querying Authorizables entities. | ||||
| type AuthorizablesQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Authorizables | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the AuthorizablesQuery builder. | ||||
| func (aq *AuthorizablesQuery) Where(ps ...predicate.Authorizables) *AuthorizablesQuery { | ||||
| 	aq.predicates = append(aq.predicates, ps...) | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (aq *AuthorizablesQuery) Limit(limit int) *AuthorizablesQuery { | ||||
| 	aq.limit = &limit | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (aq *AuthorizablesQuery) Offset(offset int) *AuthorizablesQuery { | ||||
| 	aq.offset = &offset | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // 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 (aq *AuthorizablesQuery) Unique(unique bool) *AuthorizablesQuery { | ||||
| 	aq.unique = &unique | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (aq *AuthorizablesQuery) Order(o ...OrderFunc) *AuthorizablesQuery { | ||||
| 	aq.order = append(aq.order, o...) | ||||
| 	return aq | ||||
| } | ||||
|  | ||||
| // First returns the first Authorizables entity from the query. | ||||
| // Returns a *NotFoundError when no Authorizables was found. | ||||
| func (aq *AuthorizablesQuery) First(ctx context.Context) (*Authorizables, error) { | ||||
| 	nodes, err := aq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{authorizables.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) FirstX(ctx context.Context) *Authorizables { | ||||
| 	node, err := aq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Authorizables ID from the query. | ||||
| // Returns a *NotFoundError when no Authorizables ID was found. | ||||
| func (aq *AuthorizablesQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = aq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{authorizables.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := aq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Authorizables entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Authorizables entity is found. | ||||
| // Returns a *NotFoundError when no Authorizables entities are found. | ||||
| func (aq *AuthorizablesQuery) Only(ctx context.Context) (*Authorizables, error) { | ||||
| 	nodes, err := aq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{authorizables.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{authorizables.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) OnlyX(ctx context.Context) *Authorizables { | ||||
| 	node, err := aq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Authorizables ID in the query. | ||||
| // Returns a *NotSingularError when more than one Authorizables ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (aq *AuthorizablesQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = aq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{authorizables.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{authorizables.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := aq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of AuthorizablesSlice. | ||||
| func (aq *AuthorizablesQuery) All(ctx context.Context) ([]*Authorizables, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return aq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) AllX(ctx context.Context) []*Authorizables { | ||||
| 	nodes, err := aq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Authorizables IDs. | ||||
| func (aq *AuthorizablesQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := aq.Select(authorizables.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := aq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (aq *AuthorizablesQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return aq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := aq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (aq *AuthorizablesQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := aq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return aq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (aq *AuthorizablesQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := aq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the AuthorizablesQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (aq *AuthorizablesQuery) Clone() *AuthorizablesQuery { | ||||
| 	if aq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &AuthorizablesQuery{ | ||||
| 		config:     aq.config, | ||||
| 		limit:      aq.limit, | ||||
| 		offset:     aq.offset, | ||||
| 		order:      append([]OrderFunc{}, aq.order...), | ||||
| 		predicates: append([]predicate.Authorizables{}, aq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    aq.sql.Clone(), | ||||
| 		path:   aq.path, | ||||
| 		unique: aq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Username string `json:"username,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Authorizables.Query(). | ||||
| //		GroupBy(authorizables.FieldUsername). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (aq *AuthorizablesQuery) GroupBy(field string, fields ...string) *AuthorizablesGroupBy { | ||||
| 	grbuild := &AuthorizablesGroupBy{config: aq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := aq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return aq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = authorizables.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Username string `json:"username,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Authorizables.Query(). | ||||
| //		Select(authorizables.FieldUsername). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (aq *AuthorizablesQuery) Select(fields ...string) *AuthorizablesSelect { | ||||
| 	aq.fields = append(aq.fields, fields...) | ||||
| 	selbuild := &AuthorizablesSelect{AuthorizablesQuery: aq} | ||||
| 	selbuild.label = authorizables.Label | ||||
| 	selbuild.flds, selbuild.scan = &aq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range aq.fields { | ||||
| 		if !authorizables.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if aq.path != nil { | ||||
| 		prev, err := aq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		aq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Authorizables, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Authorizables{} | ||||
| 		_spec = aq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Authorizables).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Authorizables{config: aq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := aq.querySpec() | ||||
| 	_spec.Node.Columns = aq.fields | ||||
| 	if len(aq.fields) > 0 { | ||||
| 		_spec.Unique = aq.unique != nil && *aq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, aq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := aq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   authorizables.Table, | ||||
| 			Columns: authorizables.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: authorizables.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   aq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := aq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := aq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, authorizables.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != authorizables.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := aq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := aq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := aq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := aq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (aq *AuthorizablesQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(aq.driver.Dialect()) | ||||
| 	t1 := builder.Table(authorizables.Table) | ||||
| 	columns := aq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = authorizables.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if aq.sql != nil { | ||||
| 		selector = aq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if aq.unique != nil && *aq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range aq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range aq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := aq.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 := aq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // AuthorizablesGroupBy is the group-by builder for Authorizables entities. | ||||
| type AuthorizablesGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (agb *AuthorizablesGroupBy) Aggregate(fns ...AggregateFunc) *AuthorizablesGroupBy { | ||||
| 	agb.fns = append(agb.fns, fns...) | ||||
| 	return agb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (agb *AuthorizablesGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := agb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	agb.sql = query | ||||
| 	return agb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (agb *AuthorizablesGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range agb.fields { | ||||
| 		if !authorizables.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := agb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := agb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (agb *AuthorizablesGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := agb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(agb.fns)) | ||||
| 	for _, fn := range agb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(agb.fields)+len(agb.fns)) | ||||
| 		for _, f := range agb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(agb.fields...)...) | ||||
| } | ||||
|  | ||||
| // AuthorizablesSelect is the builder for selecting fields of Authorizables entities. | ||||
| type AuthorizablesSelect struct { | ||||
| 	*AuthorizablesQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (as *AuthorizablesSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := as.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	as.sql = as.AuthorizablesQuery.sqlQuery(ctx) | ||||
| 	return as.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (as *AuthorizablesSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := as.sql.Query() | ||||
| 	if err := as.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										349
									
								
								ent/authorizables_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										349
									
								
								ent/authorizables_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,349 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // AuthorizablesUpdate is the builder for updating Authorizables entities. | ||||
| type AuthorizablesUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *AuthorizablesMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the AuthorizablesUpdate builder. | ||||
| func (au *AuthorizablesUpdate) Where(ps ...predicate.Authorizables) *AuthorizablesUpdate { | ||||
| 	au.mutation.Where(ps...) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetUsername sets the "username" field. | ||||
| func (au *AuthorizablesUpdate) SetUsername(s string) *AuthorizablesUpdate { | ||||
| 	au.mutation.SetUsername(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetPassword sets the "password" field. | ||||
| func (au *AuthorizablesUpdate) SetPassword(s string) *AuthorizablesUpdate { | ||||
| 	au.mutation.SetPassword(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (au *AuthorizablesUpdate) SetServerid(s string) *AuthorizablesUpdate { | ||||
| 	au.mutation.SetServerid(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (au *AuthorizablesUpdate) SetUserid(s string) *AuthorizablesUpdate { | ||||
| 	au.mutation.SetUserid(s) | ||||
| 	return au | ||||
| } | ||||
|  | ||||
| // Mutation returns the AuthorizablesMutation object of the builder. | ||||
| func (au *AuthorizablesUpdate) Mutation() *AuthorizablesMutation { | ||||
| 	return au.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (au *AuthorizablesUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(au.hooks) == 0 { | ||||
| 		affected, err = au.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*AuthorizablesMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			au.mutation = mutation | ||||
| 			affected, err = au.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(au.hooks) - 1; i >= 0; i-- { | ||||
| 			if au.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = au.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, au.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (au *AuthorizablesUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := au.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (au *AuthorizablesUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := au.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (au *AuthorizablesUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := au.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (au *AuthorizablesUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   authorizables.Table, | ||||
| 			Columns: authorizables.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: authorizables.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := au.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Username(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUsername, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Password(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldPassword, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := au.mutation.Userid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUserid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{authorizables.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // AuthorizablesUpdateOne is the builder for updating a single Authorizables entity. | ||||
| type AuthorizablesUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *AuthorizablesMutation | ||||
| } | ||||
|  | ||||
| // SetUsername sets the "username" field. | ||||
| func (auo *AuthorizablesUpdateOne) SetUsername(s string) *AuthorizablesUpdateOne { | ||||
| 	auo.mutation.SetUsername(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetPassword sets the "password" field. | ||||
| func (auo *AuthorizablesUpdateOne) SetPassword(s string) *AuthorizablesUpdateOne { | ||||
| 	auo.mutation.SetPassword(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (auo *AuthorizablesUpdateOne) SetServerid(s string) *AuthorizablesUpdateOne { | ||||
| 	auo.mutation.SetServerid(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (auo *AuthorizablesUpdateOne) SetUserid(s string) *AuthorizablesUpdateOne { | ||||
| 	auo.mutation.SetUserid(s) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // Mutation returns the AuthorizablesMutation object of the builder. | ||||
| func (auo *AuthorizablesUpdateOne) Mutation() *AuthorizablesMutation { | ||||
| 	return auo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (auo *AuthorizablesUpdateOne) Select(field string, fields ...string) *AuthorizablesUpdateOne { | ||||
| 	auo.fields = append([]string{field}, fields...) | ||||
| 	return auo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Authorizables entity. | ||||
| func (auo *AuthorizablesUpdateOne) Save(ctx context.Context) (*Authorizables, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Authorizables | ||||
| 	) | ||||
| 	if len(auo.hooks) == 0 { | ||||
| 		node, err = auo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*AuthorizablesMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			auo.mutation = mutation | ||||
| 			node, err = auo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(auo.hooks) - 1; i >= 0; i-- { | ||||
| 			if auo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = auo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, auo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Authorizables) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from AuthorizablesMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (auo *AuthorizablesUpdateOne) SaveX(ctx context.Context) *Authorizables { | ||||
| 	node, err := auo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (auo *AuthorizablesUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := auo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (auo *AuthorizablesUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := auo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (auo *AuthorizablesUpdateOne) sqlSave(ctx context.Context) (_node *Authorizables, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   authorizables.Table, | ||||
| 			Columns: authorizables.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: authorizables.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := auo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Authorizables.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := auo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, authorizables.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !authorizables.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != authorizables.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := auo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Username(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUsername, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Password(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldPassword, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := auo.mutation.Userid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: authorizables.FieldUserid, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Authorizables{config: auo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, auo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{authorizables.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										110
									
								
								ent/blacklist.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								ent/blacklist.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,110 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| ) | ||||
|  | ||||
| // Blacklist is the model entity for the Blacklist schema. | ||||
| type Blacklist struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Word holds the value of the "word" field. | ||||
| 	Word string `json:"word,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Blacklist) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case blacklist.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case blacklist.FieldServerid, blacklist.FieldWord: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Blacklist", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Blacklist fields. | ||||
| func (b *Blacklist) assignValues(columns []string, values []interface{}) 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 blacklist.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			b.ID = int(value.Int64) | ||||
| 		case blacklist.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				b.Serverid = value.String | ||||
| 			} | ||||
| 		case blacklist.FieldWord: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field word", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				b.Word = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Blacklist. | ||||
| // Note that you need to call Blacklist.Unwrap() before calling this method if this Blacklist | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (b *Blacklist) Update() *BlacklistUpdateOne { | ||||
| 	return (&BlacklistClient{config: b.config}).UpdateOne(b) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Blacklist 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 (b *Blacklist) Unwrap() *Blacklist { | ||||
| 	_tx, ok := b.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Blacklist is not a transactional entity") | ||||
| 	} | ||||
| 	b.config.driver = _tx.drv | ||||
| 	return b | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (b *Blacklist) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Blacklist(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", b.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(b.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("word=") | ||||
| 	builder.WriteString(b.Word) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // Blacklists is a parsable slice of Blacklist. | ||||
| type Blacklists []*Blacklist | ||||
|  | ||||
| func (b Blacklists) config(cfg config) { | ||||
| 	for _i := range b { | ||||
| 		b[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										33
									
								
								ent/blacklist/blacklist.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								ent/blacklist/blacklist.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package blacklist | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the blacklist type in the database. | ||||
| 	Label = "blacklist" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldWord holds the string denoting the word field in the database. | ||||
| 	FieldWord = "word" | ||||
| 	// Table holds the table name of the blacklist in the database. | ||||
| 	Table = "blacklists" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for blacklist fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldWord, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										347
									
								
								ent/blacklist/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										347
									
								
								ent/blacklist/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,347 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package blacklist | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Word applies equality check predicate on the "word" field. It's identical to WordEQ. | ||||
| func Word(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Blacklist { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Blacklist { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordEQ applies the EQ predicate on the "word" field. | ||||
| func WordEQ(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordNEQ applies the NEQ predicate on the "word" field. | ||||
| func WordNEQ(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordIn applies the In predicate on the "word" field. | ||||
| func WordIn(vs ...string) predicate.Blacklist { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldWord), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordNotIn applies the NotIn predicate on the "word" field. | ||||
| func WordNotIn(vs ...string) predicate.Blacklist { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldWord), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordGT applies the GT predicate on the "word" field. | ||||
| func WordGT(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordGTE applies the GTE predicate on the "word" field. | ||||
| func WordGTE(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordLT applies the LT predicate on the "word" field. | ||||
| func WordLT(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordLTE applies the LTE predicate on the "word" field. | ||||
| func WordLTE(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordContains applies the Contains predicate on the "word" field. | ||||
| func WordContains(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordHasPrefix applies the HasPrefix predicate on the "word" field. | ||||
| func WordHasPrefix(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordHasSuffix applies the HasSuffix predicate on the "word" field. | ||||
| func WordHasSuffix(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordEqualFold applies the EqualFold predicate on the "word" field. | ||||
| func WordEqualFold(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WordContainsFold applies the ContainsFold predicate on the "word" field. | ||||
| func WordContainsFold(v string) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldWord), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Blacklist) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Blacklist) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Blacklist) predicate.Blacklist { | ||||
| 	return predicate.Blacklist(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										255
									
								
								ent/blacklist_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								ent/blacklist_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,255 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| ) | ||||
|  | ||||
| // BlacklistCreate is the builder for creating a Blacklist entity. | ||||
| type BlacklistCreate struct { | ||||
| 	config | ||||
| 	mutation *BlacklistMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (bc *BlacklistCreate) SetServerid(s string) *BlacklistCreate { | ||||
| 	bc.mutation.SetServerid(s) | ||||
| 	return bc | ||||
| } | ||||
|  | ||||
| // SetWord sets the "word" field. | ||||
| func (bc *BlacklistCreate) SetWord(s string) *BlacklistCreate { | ||||
| 	bc.mutation.SetWord(s) | ||||
| 	return bc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (bc *BlacklistCreate) SetID(i int) *BlacklistCreate { | ||||
| 	bc.mutation.SetID(i) | ||||
| 	return bc | ||||
| } | ||||
|  | ||||
| // Mutation returns the BlacklistMutation object of the builder. | ||||
| func (bc *BlacklistCreate) Mutation() *BlacklistMutation { | ||||
| 	return bc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Blacklist in the database. | ||||
| func (bc *BlacklistCreate) Save(ctx context.Context) (*Blacklist, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Blacklist | ||||
| 	) | ||||
| 	if len(bc.hooks) == 0 { | ||||
| 		if err = bc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = bc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*BlacklistMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = bc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			bc.mutation = mutation | ||||
| 			if node, err = bc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(bc.hooks) - 1; i >= 0; i-- { | ||||
| 			if bc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = bc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, bc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Blacklist) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from BlacklistMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (bc *BlacklistCreate) SaveX(ctx context.Context) *Blacklist { | ||||
| 	v, err := bc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (bc *BlacklistCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := bc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (bc *BlacklistCreate) ExecX(ctx context.Context) { | ||||
| 	if err := bc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (bc *BlacklistCreate) check() error { | ||||
| 	if _, ok := bc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Blacklist.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := bc.mutation.Word(); !ok { | ||||
| 		return &ValidationError{Name: "word", err: errors.New(`ent: missing required field "Blacklist.word"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (bc *BlacklistCreate) sqlSave(ctx context.Context) (*Blacklist, error) { | ||||
| 	_node, _spec := bc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (bc *BlacklistCreate) createSpec() (*Blacklist, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Blacklist{config: bc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: blacklist.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: blacklist.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := bc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := bc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := bc.mutation.Word(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldWord, | ||||
| 		}) | ||||
| 		_node.Word = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // BlacklistCreateBulk is the builder for creating many Blacklist entities in bulk. | ||||
| type BlacklistCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*BlacklistCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Blacklist entities in the database. | ||||
| func (bcb *BlacklistCreateBulk) Save(ctx context.Context) ([]*Blacklist, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(bcb.builders)) | ||||
| 	nodes := make([]*Blacklist, len(bcb.builders)) | ||||
| 	mutators := make([]Mutator, len(bcb.builders)) | ||||
| 	for i := range bcb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := bcb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*BlacklistMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, bcb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, bcb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, bcb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (bcb *BlacklistCreateBulk) SaveX(ctx context.Context) []*Blacklist { | ||||
| 	v, err := bcb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (bcb *BlacklistCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := bcb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (bcb *BlacklistCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := bcb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/blacklist_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/blacklist_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // BlacklistDelete is the builder for deleting a Blacklist entity. | ||||
| type BlacklistDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *BlacklistMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the BlacklistDelete builder. | ||||
| func (bd *BlacklistDelete) Where(ps ...predicate.Blacklist) *BlacklistDelete { | ||||
| 	bd.mutation.Where(ps...) | ||||
| 	return bd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (bd *BlacklistDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(bd.hooks) == 0 { | ||||
| 		affected, err = bd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*BlacklistMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			bd.mutation = mutation | ||||
| 			affected, err = bd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(bd.hooks) - 1; i >= 0; i-- { | ||||
| 			if bd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = bd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, bd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (bd *BlacklistDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := bd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (bd *BlacklistDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: blacklist.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: blacklist.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := bd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // BlacklistDeleteOne is the builder for deleting a single Blacklist entity. | ||||
| type BlacklistDeleteOne struct { | ||||
| 	bd *BlacklistDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (bdo *BlacklistDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := bdo.bd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{blacklist.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (bdo *BlacklistDeleteOne) ExecX(ctx context.Context) { | ||||
| 	bdo.bd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/blacklist_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/blacklist_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // BlacklistQuery is the builder for querying Blacklist entities. | ||||
| type BlacklistQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Blacklist | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the BlacklistQuery builder. | ||||
| func (bq *BlacklistQuery) Where(ps ...predicate.Blacklist) *BlacklistQuery { | ||||
| 	bq.predicates = append(bq.predicates, ps...) | ||||
| 	return bq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (bq *BlacklistQuery) Limit(limit int) *BlacklistQuery { | ||||
| 	bq.limit = &limit | ||||
| 	return bq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (bq *BlacklistQuery) Offset(offset int) *BlacklistQuery { | ||||
| 	bq.offset = &offset | ||||
| 	return bq | ||||
| } | ||||
|  | ||||
| // 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 (bq *BlacklistQuery) Unique(unique bool) *BlacklistQuery { | ||||
| 	bq.unique = &unique | ||||
| 	return bq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (bq *BlacklistQuery) Order(o ...OrderFunc) *BlacklistQuery { | ||||
| 	bq.order = append(bq.order, o...) | ||||
| 	return bq | ||||
| } | ||||
|  | ||||
| // First returns the first Blacklist entity from the query. | ||||
| // Returns a *NotFoundError when no Blacklist was found. | ||||
| func (bq *BlacklistQuery) First(ctx context.Context) (*Blacklist, error) { | ||||
| 	nodes, err := bq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{blacklist.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) FirstX(ctx context.Context) *Blacklist { | ||||
| 	node, err := bq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Blacklist ID from the query. | ||||
| // Returns a *NotFoundError when no Blacklist ID was found. | ||||
| func (bq *BlacklistQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = bq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{blacklist.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := bq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Blacklist entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Blacklist entity is found. | ||||
| // Returns a *NotFoundError when no Blacklist entities are found. | ||||
| func (bq *BlacklistQuery) Only(ctx context.Context) (*Blacklist, error) { | ||||
| 	nodes, err := bq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{blacklist.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{blacklist.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) OnlyX(ctx context.Context) *Blacklist { | ||||
| 	node, err := bq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Blacklist ID in the query. | ||||
| // Returns a *NotSingularError when more than one Blacklist ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (bq *BlacklistQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = bq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{blacklist.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{blacklist.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := bq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of Blacklists. | ||||
| func (bq *BlacklistQuery) All(ctx context.Context) ([]*Blacklist, error) { | ||||
| 	if err := bq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return bq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) AllX(ctx context.Context) []*Blacklist { | ||||
| 	nodes, err := bq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Blacklist IDs. | ||||
| func (bq *BlacklistQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := bq.Select(blacklist.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := bq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (bq *BlacklistQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := bq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return bq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := bq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (bq *BlacklistQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := bq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return bq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (bq *BlacklistQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := bq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the BlacklistQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (bq *BlacklistQuery) Clone() *BlacklistQuery { | ||||
| 	if bq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &BlacklistQuery{ | ||||
| 		config:     bq.config, | ||||
| 		limit:      bq.limit, | ||||
| 		offset:     bq.offset, | ||||
| 		order:      append([]OrderFunc{}, bq.order...), | ||||
| 		predicates: append([]predicate.Blacklist{}, bq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    bq.sql.Clone(), | ||||
| 		path:   bq.path, | ||||
| 		unique: bq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Blacklist.Query(). | ||||
| //		GroupBy(blacklist.FieldServerid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (bq *BlacklistQuery) GroupBy(field string, fields ...string) *BlacklistGroupBy { | ||||
| 	grbuild := &BlacklistGroupBy{config: bq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := bq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return bq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = blacklist.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Blacklist.Query(). | ||||
| //		Select(blacklist.FieldServerid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (bq *BlacklistQuery) Select(fields ...string) *BlacklistSelect { | ||||
| 	bq.fields = append(bq.fields, fields...) | ||||
| 	selbuild := &BlacklistSelect{BlacklistQuery: bq} | ||||
| 	selbuild.label = blacklist.Label | ||||
| 	selbuild.flds, selbuild.scan = &bq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range bq.fields { | ||||
| 		if !blacklist.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if bq.path != nil { | ||||
| 		prev, err := bq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		bq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Blacklist, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Blacklist{} | ||||
| 		_spec = bq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Blacklist).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Blacklist{config: bq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := bq.querySpec() | ||||
| 	_spec.Node.Columns = bq.fields | ||||
| 	if len(bq.fields) > 0 { | ||||
| 		_spec.Unique = bq.unique != nil && *bq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, bq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := bq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   blacklist.Table, | ||||
| 			Columns: blacklist.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: blacklist.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   bq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := bq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := bq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != blacklist.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := bq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := bq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := bq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := bq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (bq *BlacklistQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(bq.driver.Dialect()) | ||||
| 	t1 := builder.Table(blacklist.Table) | ||||
| 	columns := bq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = blacklist.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if bq.sql != nil { | ||||
| 		selector = bq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if bq.unique != nil && *bq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range bq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range bq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := bq.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 := bq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // BlacklistGroupBy is the group-by builder for Blacklist entities. | ||||
| type BlacklistGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (bgb *BlacklistGroupBy) Aggregate(fns ...AggregateFunc) *BlacklistGroupBy { | ||||
| 	bgb.fns = append(bgb.fns, fns...) | ||||
| 	return bgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (bgb *BlacklistGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := bgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	bgb.sql = query | ||||
| 	return bgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (bgb *BlacklistGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range bgb.fields { | ||||
| 		if !blacklist.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := bgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := bgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (bgb *BlacklistGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := bgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(bgb.fns)) | ||||
| 	for _, fn := range bgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(bgb.fields)+len(bgb.fns)) | ||||
| 		for _, f := range bgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(bgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // BlacklistSelect is the builder for selecting fields of Blacklist entities. | ||||
| type BlacklistSelect struct { | ||||
| 	*BlacklistQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (bs *BlacklistSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := bs.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	bs.sql = bs.BlacklistQuery.sqlQuery(ctx) | ||||
| 	return bs.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (bs *BlacklistSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := bs.sql.Query() | ||||
| 	if err := bs.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										297
									
								
								ent/blacklist_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										297
									
								
								ent/blacklist_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,297 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // BlacklistUpdate is the builder for updating Blacklist entities. | ||||
| type BlacklistUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *BlacklistMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the BlacklistUpdate builder. | ||||
| func (bu *BlacklistUpdate) Where(ps ...predicate.Blacklist) *BlacklistUpdate { | ||||
| 	bu.mutation.Where(ps...) | ||||
| 	return bu | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (bu *BlacklistUpdate) SetServerid(s string) *BlacklistUpdate { | ||||
| 	bu.mutation.SetServerid(s) | ||||
| 	return bu | ||||
| } | ||||
|  | ||||
| // SetWord sets the "word" field. | ||||
| func (bu *BlacklistUpdate) SetWord(s string) *BlacklistUpdate { | ||||
| 	bu.mutation.SetWord(s) | ||||
| 	return bu | ||||
| } | ||||
|  | ||||
| // Mutation returns the BlacklistMutation object of the builder. | ||||
| func (bu *BlacklistUpdate) Mutation() *BlacklistMutation { | ||||
| 	return bu.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (bu *BlacklistUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(bu.hooks) == 0 { | ||||
| 		affected, err = bu.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*BlacklistMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			bu.mutation = mutation | ||||
| 			affected, err = bu.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(bu.hooks) - 1; i >= 0; i-- { | ||||
| 			if bu.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = bu.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, bu.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (bu *BlacklistUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := bu.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (bu *BlacklistUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := bu.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (bu *BlacklistUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := bu.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (bu *BlacklistUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   blacklist.Table, | ||||
| 			Columns: blacklist.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: blacklist.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := bu.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := bu.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := bu.mutation.Word(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldWord, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, bu.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{blacklist.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // BlacklistUpdateOne is the builder for updating a single Blacklist entity. | ||||
| type BlacklistUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *BlacklistMutation | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (buo *BlacklistUpdateOne) SetServerid(s string) *BlacklistUpdateOne { | ||||
| 	buo.mutation.SetServerid(s) | ||||
| 	return buo | ||||
| } | ||||
|  | ||||
| // SetWord sets the "word" field. | ||||
| func (buo *BlacklistUpdateOne) SetWord(s string) *BlacklistUpdateOne { | ||||
| 	buo.mutation.SetWord(s) | ||||
| 	return buo | ||||
| } | ||||
|  | ||||
| // Mutation returns the BlacklistMutation object of the builder. | ||||
| func (buo *BlacklistUpdateOne) Mutation() *BlacklistMutation { | ||||
| 	return buo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (buo *BlacklistUpdateOne) Select(field string, fields ...string) *BlacklistUpdateOne { | ||||
| 	buo.fields = append([]string{field}, fields...) | ||||
| 	return buo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Blacklist entity. | ||||
| func (buo *BlacklistUpdateOne) Save(ctx context.Context) (*Blacklist, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Blacklist | ||||
| 	) | ||||
| 	if len(buo.hooks) == 0 { | ||||
| 		node, err = buo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*BlacklistMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			buo.mutation = mutation | ||||
| 			node, err = buo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(buo.hooks) - 1; i >= 0; i-- { | ||||
| 			if buo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = buo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, buo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Blacklist) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from BlacklistMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (buo *BlacklistUpdateOne) SaveX(ctx context.Context) *Blacklist { | ||||
| 	node, err := buo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (buo *BlacklistUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := buo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (buo *BlacklistUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := buo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (buo *BlacklistUpdateOne) sqlSave(ctx context.Context) (_node *Blacklist, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   blacklist.Table, | ||||
| 			Columns: blacklist.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: blacklist.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := buo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Blacklist.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := buo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, blacklist.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !blacklist.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != blacklist.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := buo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := buo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := buo.mutation.Word(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: blacklist.FieldWord, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Blacklist{config: buo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, buo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{blacklist.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										1280
									
								
								ent/client.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1280
									
								
								ent/client.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										70
									
								
								ent/config.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								ent/config.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/dialect" | ||||
| ) | ||||
|  | ||||
| // Option function to configure the client. | ||||
| type Option func(*config) | ||||
|  | ||||
| // Config is the configuration for the client and its builder. | ||||
| type config struct { | ||||
| 	// driver used for executing database requests. | ||||
| 	driver dialect.Driver | ||||
| 	// debug enable a debug logging. | ||||
| 	debug bool | ||||
| 	// log used for logging on debug mode. | ||||
| 	log func(...interface{}) | ||||
| 	// hooks to execute on mutations. | ||||
| 	hooks *hooks | ||||
| } | ||||
|  | ||||
| // hooks per client, for fast access. | ||||
| type hooks struct { | ||||
| 	Actions         []ent.Hook | ||||
| 	Authorizables   []ent.Hook | ||||
| 	Blacklist       []ent.Hook | ||||
| 	Logging         []ent.Hook | ||||
| 	Punishments     []ent.Hook | ||||
| 	Servers         []ent.Hook | ||||
| 	Settings        []ent.Hook | ||||
| 	Socialmedia     []ent.Hook | ||||
| 	Support         []ent.Hook | ||||
| 	SupportResponse []ent.Hook | ||||
| 	User            []ent.Hook | ||||
| 	Warns           []ent.Hook | ||||
| } | ||||
|  | ||||
| // Options applies the options on the config object. | ||||
| func (c *config) options(opts ...Option) { | ||||
| 	for _, opt := range opts { | ||||
| 		opt(c) | ||||
| 	} | ||||
| 	if c.debug { | ||||
| 		c.driver = dialect.Debug(c.driver, c.log) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Debug enables debug logging on the ent.Driver. | ||||
| func Debug() Option { | ||||
| 	return func(c *config) { | ||||
| 		c.debug = true | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Log sets the logging function for debug mode. | ||||
| func Log(fn func(...interface{})) Option { | ||||
| 	return func(c *config) { | ||||
| 		c.log = fn | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Driver configures the client driver. | ||||
| func Driver(driver dialect.Driver) Option { | ||||
| 	return func(c *config) { | ||||
| 		c.driver = driver | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										33
									
								
								ent/context.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								ent/context.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| ) | ||||
|  | ||||
| type clientCtxKey struct{} | ||||
|  | ||||
| // FromContext returns a Client stored inside a context, or nil if there isn't one. | ||||
| func FromContext(ctx context.Context) *Client { | ||||
| 	c, _ := ctx.Value(clientCtxKey{}).(*Client) | ||||
| 	return c | ||||
| } | ||||
|  | ||||
| // NewContext returns a new context with the given Client attached. | ||||
| func NewContext(parent context.Context, c *Client) context.Context { | ||||
| 	return context.WithValue(parent, clientCtxKey{}, c) | ||||
| } | ||||
|  | ||||
| type txCtxKey struct{} | ||||
|  | ||||
| // TxFromContext returns a Tx stored inside a context, or nil if there isn't one. | ||||
| func TxFromContext(ctx context.Context) *Tx { | ||||
| 	tx, _ := ctx.Value(txCtxKey{}).(*Tx) | ||||
| 	return tx | ||||
| } | ||||
|  | ||||
| // NewTxContext returns a new context with the given Tx attached. | ||||
| func NewTxContext(parent context.Context, tx *Tx) context.Context { | ||||
| 	return context.WithValue(parent, txCtxKey{}, tx) | ||||
| } | ||||
							
								
								
									
										488
									
								
								ent/ent.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										488
									
								
								ent/ent.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,488 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/authorizables" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/blacklist" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/user" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/warns" | ||||
| ) | ||||
|  | ||||
| // ent aliases to avoid import conflicts in user's code. | ||||
| type ( | ||||
| 	Op         = ent.Op | ||||
| 	Hook       = ent.Hook | ||||
| 	Value      = ent.Value | ||||
| 	Query      = ent.Query | ||||
| 	Policy     = ent.Policy | ||||
| 	Mutator    = ent.Mutator | ||||
| 	Mutation   = ent.Mutation | ||||
| 	MutateFunc = ent.MutateFunc | ||||
| ) | ||||
|  | ||||
| // OrderFunc applies an ordering on the sql selector. | ||||
| type OrderFunc func(*sql.Selector) | ||||
|  | ||||
| // columnChecker returns a function indicates if the column exists in the given column. | ||||
| func columnChecker(table string) func(string) error { | ||||
| 	checks := map[string]func(string) bool{ | ||||
| 		actions.Table:         actions.ValidColumn, | ||||
| 		authorizables.Table:   authorizables.ValidColumn, | ||||
| 		blacklist.Table:       blacklist.ValidColumn, | ||||
| 		logging.Table:         logging.ValidColumn, | ||||
| 		punishments.Table:     punishments.ValidColumn, | ||||
| 		servers.Table:         servers.ValidColumn, | ||||
| 		settings.Table:        settings.ValidColumn, | ||||
| 		socialmedia.Table:     socialmedia.ValidColumn, | ||||
| 		support.Table:         support.ValidColumn, | ||||
| 		supportresponse.Table: supportresponse.ValidColumn, | ||||
| 		user.Table:            user.ValidColumn, | ||||
| 		warns.Table:           warns.ValidColumn, | ||||
| 	} | ||||
| 	check, ok := checks[table] | ||||
| 	if !ok { | ||||
| 		return func(string) error { | ||||
| 			return fmt.Errorf("unknown table %q", table) | ||||
| 		} | ||||
| 	} | ||||
| 	return func(column string) error { | ||||
| 		if !check(column) { | ||||
| 			return fmt.Errorf("unknown column %q for table %q", column, table) | ||||
| 		} | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Asc applies the given fields in ASC order. | ||||
| func Asc(fields ...string) OrderFunc { | ||||
| 	return func(s *sql.Selector) { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		for _, f := range fields { | ||||
| 			if err := check(f); err != nil { | ||||
| 				s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			} | ||||
| 			s.OrderBy(sql.Asc(s.C(f))) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Desc applies the given fields in DESC order. | ||||
| func Desc(fields ...string) OrderFunc { | ||||
| 	return func(s *sql.Selector) { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		for _, f := range fields { | ||||
| 			if err := check(f); err != nil { | ||||
| 				s.AddError(&ValidationError{Name: f, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			} | ||||
| 			s.OrderBy(sql.Desc(s.C(f))) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // AggregateFunc applies an aggregation step on the group-by traversal/selector. | ||||
| type AggregateFunc func(*sql.Selector) string | ||||
|  | ||||
| // As is a pseudo aggregation function for renaming another other functions with custom names. For example: | ||||
| // | ||||
| //	GroupBy(field1, field2). | ||||
| //	Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")). | ||||
| //	Scan(ctx, &v) | ||||
| // | ||||
| func As(fn AggregateFunc, end string) AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		return sql.As(fn(s), end) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Count applies the "count" aggregation function on each group. | ||||
| func Count() AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		return sql.Count("*") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Max applies the "max" aggregation function on the given field of each group. | ||||
| func Max(field string) AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		if err := check(field); err != nil { | ||||
| 			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			return "" | ||||
| 		} | ||||
| 		return sql.Max(s.C(field)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Mean applies the "mean" aggregation function on the given field of each group. | ||||
| func Mean(field string) AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		if err := check(field); err != nil { | ||||
| 			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			return "" | ||||
| 		} | ||||
| 		return sql.Avg(s.C(field)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Min applies the "min" aggregation function on the given field of each group. | ||||
| func Min(field string) AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		if err := check(field); err != nil { | ||||
| 			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			return "" | ||||
| 		} | ||||
| 		return sql.Min(s.C(field)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Sum applies the "sum" aggregation function on the given field of each group. | ||||
| func Sum(field string) AggregateFunc { | ||||
| 	return func(s *sql.Selector) string { | ||||
| 		check := columnChecker(s.TableName()) | ||||
| 		if err := check(field); err != nil { | ||||
| 			s.AddError(&ValidationError{Name: field, err: fmt.Errorf("ent: %w", err)}) | ||||
| 			return "" | ||||
| 		} | ||||
| 		return sql.Sum(s.C(field)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ValidationError returns when validating a field or edge fails. | ||||
| type ValidationError struct { | ||||
| 	Name string // Field or edge name. | ||||
| 	err  error | ||||
| } | ||||
|  | ||||
| // Error implements the error interface. | ||||
| func (e *ValidationError) Error() string { | ||||
| 	return e.err.Error() | ||||
| } | ||||
|  | ||||
| // Unwrap implements the errors.Wrapper interface. | ||||
| func (e *ValidationError) Unwrap() error { | ||||
| 	return e.err | ||||
| } | ||||
|  | ||||
| // IsValidationError returns a boolean indicating whether the error is a validation error. | ||||
| func IsValidationError(err error) bool { | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	var e *ValidationError | ||||
| 	return errors.As(err, &e) | ||||
| } | ||||
|  | ||||
| // NotFoundError returns when trying to fetch a specific entity and it was not found in the database. | ||||
| type NotFoundError struct { | ||||
| 	label string | ||||
| } | ||||
|  | ||||
| // Error implements the error interface. | ||||
| func (e *NotFoundError) Error() string { | ||||
| 	return "ent: " + e.label + " not found" | ||||
| } | ||||
|  | ||||
| // IsNotFound returns a boolean indicating whether the error is a not found error. | ||||
| func IsNotFound(err error) bool { | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	var e *NotFoundError | ||||
| 	return errors.As(err, &e) | ||||
| } | ||||
|  | ||||
| // MaskNotFound masks not found error. | ||||
| func MaskNotFound(err error) error { | ||||
| 	if IsNotFound(err) { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // NotSingularError returns when trying to fetch a singular entity and more then one was found in the database. | ||||
| type NotSingularError struct { | ||||
| 	label string | ||||
| } | ||||
|  | ||||
| // Error implements the error interface. | ||||
| func (e *NotSingularError) Error() string { | ||||
| 	return "ent: " + e.label + " not singular" | ||||
| } | ||||
|  | ||||
| // IsNotSingular returns a boolean indicating whether the error is a not singular error. | ||||
| func IsNotSingular(err error) bool { | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	var e *NotSingularError | ||||
| 	return errors.As(err, &e) | ||||
| } | ||||
|  | ||||
| // NotLoadedError returns when trying to get a node that was not loaded by the query. | ||||
| type NotLoadedError struct { | ||||
| 	edge string | ||||
| } | ||||
|  | ||||
| // Error implements the error interface. | ||||
| func (e *NotLoadedError) Error() string { | ||||
| 	return "ent: " + e.edge + " edge was not loaded" | ||||
| } | ||||
|  | ||||
| // IsNotLoaded returns a boolean indicating whether the error is a not loaded error. | ||||
| func IsNotLoaded(err error) bool { | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	var e *NotLoadedError | ||||
| 	return errors.As(err, &e) | ||||
| } | ||||
|  | ||||
| // ConstraintError returns when trying to create/update one or more entities and | ||||
| // one or more of their constraints failed. For example, violation of edge or | ||||
| // field uniqueness. | ||||
| type ConstraintError struct { | ||||
| 	msg  string | ||||
| 	wrap error | ||||
| } | ||||
|  | ||||
| // Error implements the error interface. | ||||
| func (e ConstraintError) Error() string { | ||||
| 	return "ent: constraint failed: " + e.msg | ||||
| } | ||||
|  | ||||
| // Unwrap implements the errors.Wrapper interface. | ||||
| func (e *ConstraintError) Unwrap() error { | ||||
| 	return e.wrap | ||||
| } | ||||
|  | ||||
| // IsConstraintError returns a boolean indicating whether the error is a constraint failure. | ||||
| func IsConstraintError(err error) bool { | ||||
| 	if err == nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	var e *ConstraintError | ||||
| 	return errors.As(err, &e) | ||||
| } | ||||
|  | ||||
| // selector embedded by the different Select/GroupBy builders. | ||||
| type selector struct { | ||||
| 	label string | ||||
| 	flds  *[]string | ||||
| 	scan  func(context.Context, interface{}) error | ||||
| } | ||||
|  | ||||
| // ScanX is like Scan, but panics if an error occurs. | ||||
| func (s *selector) ScanX(ctx context.Context, v interface{}) { | ||||
| 	if err := s.scan(ctx, v); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Strings returns list of strings from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Strings(ctx context.Context) ([]string, error) { | ||||
| 	if len(*s.flds) > 1 { | ||||
| 		return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field") | ||||
| 	} | ||||
| 	var v []string | ||||
| 	if err := s.scan(ctx, &v); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return v, nil | ||||
| } | ||||
|  | ||||
| // StringsX is like Strings, but panics if an error occurs. | ||||
| func (s *selector) StringsX(ctx context.Context) []string { | ||||
| 	v, err := s.Strings(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // String returns a single string from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) String(ctx context.Context) (_ string, err error) { | ||||
| 	var v []string | ||||
| 	if v, err = s.Strings(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(v) { | ||||
| 	case 1: | ||||
| 		return v[0], nil | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{s.label} | ||||
| 	default: | ||||
| 		err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v)) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // StringX is like String, but panics if an error occurs. | ||||
| func (s *selector) StringX(ctx context.Context) string { | ||||
| 	v, err := s.String(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Ints returns list of ints from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Ints(ctx context.Context) ([]int, error) { | ||||
| 	if len(*s.flds) > 1 { | ||||
| 		return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field") | ||||
| 	} | ||||
| 	var v []int | ||||
| 	if err := s.scan(ctx, &v); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return v, nil | ||||
| } | ||||
|  | ||||
| // IntsX is like Ints, but panics if an error occurs. | ||||
| func (s *selector) IntsX(ctx context.Context) []int { | ||||
| 	v, err := s.Ints(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Int returns a single int from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Int(ctx context.Context) (_ int, err error) { | ||||
| 	var v []int | ||||
| 	if v, err = s.Ints(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(v) { | ||||
| 	case 1: | ||||
| 		return v[0], nil | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{s.label} | ||||
| 	default: | ||||
| 		err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v)) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // IntX is like Int, but panics if an error occurs. | ||||
| func (s *selector) IntX(ctx context.Context) int { | ||||
| 	v, err := s.Int(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Float64s returns list of float64s from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Float64s(ctx context.Context) ([]float64, error) { | ||||
| 	if len(*s.flds) > 1 { | ||||
| 		return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field") | ||||
| 	} | ||||
| 	var v []float64 | ||||
| 	if err := s.scan(ctx, &v); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return v, nil | ||||
| } | ||||
|  | ||||
| // Float64sX is like Float64s, but panics if an error occurs. | ||||
| func (s *selector) Float64sX(ctx context.Context) []float64 { | ||||
| 	v, err := s.Float64s(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Float64 returns a single float64 from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Float64(ctx context.Context) (_ float64, err error) { | ||||
| 	var v []float64 | ||||
| 	if v, err = s.Float64s(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(v) { | ||||
| 	case 1: | ||||
| 		return v[0], nil | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{s.label} | ||||
| 	default: | ||||
| 		err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v)) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Float64X is like Float64, but panics if an error occurs. | ||||
| func (s *selector) Float64X(ctx context.Context) float64 { | ||||
| 	v, err := s.Float64(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Bools returns list of bools from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Bools(ctx context.Context) ([]bool, error) { | ||||
| 	if len(*s.flds) > 1 { | ||||
| 		return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field") | ||||
| 	} | ||||
| 	var v []bool | ||||
| 	if err := s.scan(ctx, &v); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return v, nil | ||||
| } | ||||
|  | ||||
| // BoolsX is like Bools, but panics if an error occurs. | ||||
| func (s *selector) BoolsX(ctx context.Context) []bool { | ||||
| 	v, err := s.Bools(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Bool returns a single bool from a selector. It is only allowed when selecting one field. | ||||
| func (s *selector) Bool(ctx context.Context) (_ bool, err error) { | ||||
| 	var v []bool | ||||
| 	if v, err = s.Bools(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(v) { | ||||
| 	case 1: | ||||
| 		return v[0], nil | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{s.label} | ||||
| 	default: | ||||
| 		err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v)) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // BoolX is like Bool, but panics if an error occurs. | ||||
| func (s *selector) BoolX(ctx context.Context) bool { | ||||
| 	v, err := s.Bool(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // queryHook describes an internal hook for the different sqlAll methods. | ||||
| type queryHook func(context.Context, *sqlgraph.QuerySpec) | ||||
							
								
								
									
										84
									
								
								ent/enttest/enttest.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								ent/enttest/enttest.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,84 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package enttest | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent" | ||||
| 	// required by schema hooks. | ||||
| 	_ "github.com/FrankenBotDev/FrankenAPI/ent/runtime" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/schema" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/migrate" | ||||
| ) | ||||
|  | ||||
| type ( | ||||
| 	// TestingT is the interface that is shared between | ||||
| 	// testing.T and testing.B and used by enttest. | ||||
| 	TestingT interface { | ||||
| 		FailNow() | ||||
| 		Error(...interface{}) | ||||
| 	} | ||||
|  | ||||
| 	// Option configures client creation. | ||||
| 	Option func(*options) | ||||
|  | ||||
| 	options struct { | ||||
| 		opts        []ent.Option | ||||
| 		migrateOpts []schema.MigrateOption | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| // WithOptions forwards options to client creation. | ||||
| func WithOptions(opts ...ent.Option) Option { | ||||
| 	return func(o *options) { | ||||
| 		o.opts = append(o.opts, opts...) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // WithMigrateOptions forwards options to auto migration. | ||||
| func WithMigrateOptions(opts ...schema.MigrateOption) Option { | ||||
| 	return func(o *options) { | ||||
| 		o.migrateOpts = append(o.migrateOpts, opts...) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func newOptions(opts []Option) *options { | ||||
| 	o := &options{} | ||||
| 	for _, opt := range opts { | ||||
| 		opt(o) | ||||
| 	} | ||||
| 	return o | ||||
| } | ||||
|  | ||||
| // Open calls ent.Open and auto-run migration. | ||||
| func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Client { | ||||
| 	o := newOptions(opts) | ||||
| 	c, err := ent.Open(driverName, dataSourceName, o.opts...) | ||||
| 	if err != nil { | ||||
| 		t.Error(err) | ||||
| 		t.FailNow() | ||||
| 	} | ||||
| 	migrateSchema(t, c, o) | ||||
| 	return c | ||||
| } | ||||
|  | ||||
| // NewClient calls ent.NewClient and auto-run migration. | ||||
| func NewClient(t TestingT, opts ...Option) *ent.Client { | ||||
| 	o := newOptions(opts) | ||||
| 	c := ent.NewClient(o.opts...) | ||||
| 	migrateSchema(t, c, o) | ||||
| 	return c | ||||
| } | ||||
| func migrateSchema(t TestingT, c *ent.Client, o *options) { | ||||
| 	tables, err := schema.CopyTables(migrate.Tables) | ||||
| 	if err != nil { | ||||
| 		t.Error(err) | ||||
| 		t.FailNow() | ||||
| 	} | ||||
| 	if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil { | ||||
| 		t.Error(err) | ||||
| 		t.FailNow() | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										3
									
								
								ent/generate.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								ent/generate.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,3 @@ | ||||
| package ent | ||||
|  | ||||
| //go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema | ||||
							
								
								
									
										347
									
								
								ent/hook/hook.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										347
									
								
								ent/hook/hook.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,347 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package hook | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent" | ||||
| ) | ||||
|  | ||||
| // The ActionsFunc type is an adapter to allow the use of ordinary | ||||
| // function as Actions mutator. | ||||
| type ActionsFunc func(context.Context, *ent.ActionsMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f ActionsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.ActionsMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ActionsMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The AuthorizablesFunc type is an adapter to allow the use of ordinary | ||||
| // function as Authorizables mutator. | ||||
| type AuthorizablesFunc func(context.Context, *ent.AuthorizablesMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f AuthorizablesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.AuthorizablesMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.AuthorizablesMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The BlacklistFunc type is an adapter to allow the use of ordinary | ||||
| // function as Blacklist mutator. | ||||
| type BlacklistFunc func(context.Context, *ent.BlacklistMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f BlacklistFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.BlacklistMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.BlacklistMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The LoggingFunc type is an adapter to allow the use of ordinary | ||||
| // function as Logging mutator. | ||||
| type LoggingFunc func(context.Context, *ent.LoggingMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f LoggingFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.LoggingMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.LoggingMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The PunishmentsFunc type is an adapter to allow the use of ordinary | ||||
| // function as Punishments mutator. | ||||
| type PunishmentsFunc func(context.Context, *ent.PunishmentsMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f PunishmentsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.PunishmentsMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PunishmentsMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The ServersFunc type is an adapter to allow the use of ordinary | ||||
| // function as Servers mutator. | ||||
| type ServersFunc func(context.Context, *ent.ServersMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f ServersFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.ServersMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.ServersMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The SettingsFunc type is an adapter to allow the use of ordinary | ||||
| // function as Settings mutator. | ||||
| type SettingsFunc func(context.Context, *ent.SettingsMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f SettingsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.SettingsMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SettingsMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The SocialmediaFunc type is an adapter to allow the use of ordinary | ||||
| // function as Socialmedia mutator. | ||||
| type SocialmediaFunc func(context.Context, *ent.SocialmediaMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f SocialmediaFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.SocialmediaMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SocialmediaMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The SupportFunc type is an adapter to allow the use of ordinary | ||||
| // function as Support mutator. | ||||
| type SupportFunc func(context.Context, *ent.SupportMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f SupportFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.SupportMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SupportMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The SupportResponseFunc type is an adapter to allow the use of ordinary | ||||
| // function as SupportResponse mutator. | ||||
| type SupportResponseFunc func(context.Context, *ent.SupportResponseMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f SupportResponseFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.SupportResponseMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SupportResponseMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The UserFunc type is an adapter to allow the use of ordinary | ||||
| // function as User mutator. | ||||
| type UserFunc func(context.Context, *ent.UserMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f UserFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.UserMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.UserMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // The WarnsFunc type is an adapter to allow the use of ordinary | ||||
| // function as Warns mutator. | ||||
| type WarnsFunc func(context.Context, *ent.WarnsMutation) (ent.Value, error) | ||||
|  | ||||
| // Mutate calls f(ctx, m). | ||||
| func (f WarnsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 	mv, ok := m.(*ent.WarnsMutation) | ||||
| 	if !ok { | ||||
| 		return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WarnsMutation", m) | ||||
| 	} | ||||
| 	return f(ctx, mv) | ||||
| } | ||||
|  | ||||
| // Condition is a hook condition function. | ||||
| type Condition func(context.Context, ent.Mutation) bool | ||||
|  | ||||
| // And groups conditions with the AND operator. | ||||
| func And(first, second Condition, rest ...Condition) Condition { | ||||
| 	return func(ctx context.Context, m ent.Mutation) bool { | ||||
| 		if !first(ctx, m) || !second(ctx, m) { | ||||
| 			return false | ||||
| 		} | ||||
| 		for _, cond := range rest { | ||||
| 			if !cond(ctx, m) { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Or groups conditions with the OR operator. | ||||
| func Or(first, second Condition, rest ...Condition) Condition { | ||||
| 	return func(ctx context.Context, m ent.Mutation) bool { | ||||
| 		if first(ctx, m) || second(ctx, m) { | ||||
| 			return true | ||||
| 		} | ||||
| 		for _, cond := range rest { | ||||
| 			if cond(ctx, m) { | ||||
| 				return true | ||||
| 			} | ||||
| 		} | ||||
| 		return false | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Not negates a given condition. | ||||
| func Not(cond Condition) Condition { | ||||
| 	return func(ctx context.Context, m ent.Mutation) bool { | ||||
| 		return !cond(ctx, m) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // HasOp is a condition testing mutation operation. | ||||
| func HasOp(op ent.Op) Condition { | ||||
| 	return func(_ context.Context, m ent.Mutation) bool { | ||||
| 		return m.Op().Is(op) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // HasAddedFields is a condition validating `.AddedField` on fields. | ||||
| func HasAddedFields(field string, fields ...string) Condition { | ||||
| 	return func(_ context.Context, m ent.Mutation) bool { | ||||
| 		if _, exists := m.AddedField(field); !exists { | ||||
| 			return false | ||||
| 		} | ||||
| 		for _, field := range fields { | ||||
| 			if _, exists := m.AddedField(field); !exists { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // HasClearedFields is a condition validating `.FieldCleared` on fields. | ||||
| func HasClearedFields(field string, fields ...string) Condition { | ||||
| 	return func(_ context.Context, m ent.Mutation) bool { | ||||
| 		if exists := m.FieldCleared(field); !exists { | ||||
| 			return false | ||||
| 		} | ||||
| 		for _, field := range fields { | ||||
| 			if exists := m.FieldCleared(field); !exists { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // HasFields is a condition validating `.Field` on fields. | ||||
| func HasFields(field string, fields ...string) Condition { | ||||
| 	return func(_ context.Context, m ent.Mutation) bool { | ||||
| 		if _, exists := m.Field(field); !exists { | ||||
| 			return false | ||||
| 		} | ||||
| 		for _, field := range fields { | ||||
| 			if _, exists := m.Field(field); !exists { | ||||
| 				return false | ||||
| 			} | ||||
| 		} | ||||
| 		return true | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // If executes the given hook under condition. | ||||
| // | ||||
| //	hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...))) | ||||
| // | ||||
| func If(hk ent.Hook, cond Condition) ent.Hook { | ||||
| 	return func(next ent.Mutator) ent.Mutator { | ||||
| 		return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { | ||||
| 			if cond(ctx, m) { | ||||
| 				return hk(next).Mutate(ctx, m) | ||||
| 			} | ||||
| 			return next.Mutate(ctx, m) | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // On executes the given hook only for the given operation. | ||||
| // | ||||
| //	hook.On(Log, ent.Delete|ent.Create) | ||||
| // | ||||
| func On(hk ent.Hook, op ent.Op) ent.Hook { | ||||
| 	return If(hk, HasOp(op)) | ||||
| } | ||||
|  | ||||
| // Unless skips the given hook only for the given operation. | ||||
| // | ||||
| //	hook.Unless(Log, ent.Update|ent.UpdateOne) | ||||
| // | ||||
| func Unless(hk ent.Hook, op ent.Op) ent.Hook { | ||||
| 	return If(hk, Not(HasOp(op))) | ||||
| } | ||||
|  | ||||
| // FixedError is a hook returning a fixed error. | ||||
| func FixedError(err error) ent.Hook { | ||||
| 	return func(ent.Mutator) ent.Mutator { | ||||
| 		return ent.MutateFunc(func(context.Context, ent.Mutation) (ent.Value, error) { | ||||
| 			return nil, err | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Reject returns a hook that rejects all operations that match op. | ||||
| // | ||||
| //	func (T) Hooks() []ent.Hook { | ||||
| //		return []ent.Hook{ | ||||
| //			Reject(ent.Delete|ent.Update), | ||||
| //		} | ||||
| //	} | ||||
| // | ||||
| func Reject(op ent.Op) ent.Hook { | ||||
| 	hk := FixedError(fmt.Errorf("%s operation is not allowed", op)) | ||||
| 	return On(hk, op) | ||||
| } | ||||
|  | ||||
| // Chain acts as a list of hooks and is effectively immutable. | ||||
| // Once created, it will always hold the same set of hooks in the same order. | ||||
| type Chain struct { | ||||
| 	hooks []ent.Hook | ||||
| } | ||||
|  | ||||
| // NewChain creates a new chain of hooks. | ||||
| func NewChain(hooks ...ent.Hook) Chain { | ||||
| 	return Chain{append([]ent.Hook(nil), hooks...)} | ||||
| } | ||||
|  | ||||
| // Hook chains the list of hooks and returns the final hook. | ||||
| func (c Chain) Hook() ent.Hook { | ||||
| 	return func(mutator ent.Mutator) ent.Mutator { | ||||
| 		for i := len(c.hooks) - 1; i >= 0; i-- { | ||||
| 			mutator = c.hooks[i](mutator) | ||||
| 		} | ||||
| 		return mutator | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Append extends a chain, adding the specified hook | ||||
| // as the last ones in the mutation flow. | ||||
| func (c Chain) Append(hooks ...ent.Hook) Chain { | ||||
| 	newHooks := make([]ent.Hook, 0, len(c.hooks)+len(hooks)) | ||||
| 	newHooks = append(newHooks, c.hooks...) | ||||
| 	newHooks = append(newHooks, hooks...) | ||||
| 	return Chain{newHooks} | ||||
| } | ||||
|  | ||||
| // Extend extends a chain, adding the specified chain | ||||
| // as the last ones in the mutation flow. | ||||
| func (c Chain) Extend(chain Chain) Chain { | ||||
| 	return c.Append(chain.hooks...) | ||||
| } | ||||
							
								
								
									
										132
									
								
								ent/logging.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										132
									
								
								ent/logging.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,132 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| ) | ||||
|  | ||||
| // Logging is the model entity for the Logging schema. | ||||
| type Logging struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Type holds the value of the "type" field. | ||||
| 	Type string `json:"type,omitempty"` | ||||
| 	// Commiter holds the value of the "commiter" field. | ||||
| 	Commiter string `json:"commiter,omitempty"` | ||||
| 	// Description holds the value of the "description" field. | ||||
| 	Description string `json:"description,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Logging) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case logging.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case logging.FieldServerid, logging.FieldType, logging.FieldCommiter, logging.FieldDescription: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Logging", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Logging fields. | ||||
| func (l *Logging) assignValues(columns []string, values []interface{}) 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 logging.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			l.ID = int(value.Int64) | ||||
| 		case logging.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				l.Serverid = value.String | ||||
| 			} | ||||
| 		case logging.FieldType: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field type", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				l.Type = value.String | ||||
| 			} | ||||
| 		case logging.FieldCommiter: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field commiter", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				l.Commiter = value.String | ||||
| 			} | ||||
| 		case logging.FieldDescription: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field description", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				l.Description = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Logging. | ||||
| // Note that you need to call Logging.Unwrap() before calling this method if this Logging | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (l *Logging) Update() *LoggingUpdateOne { | ||||
| 	return (&LoggingClient{config: l.config}).UpdateOne(l) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Logging 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 (l *Logging) Unwrap() *Logging { | ||||
| 	_tx, ok := l.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Logging is not a transactional entity") | ||||
| 	} | ||||
| 	l.config.driver = _tx.drv | ||||
| 	return l | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (l *Logging) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Logging(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", l.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(l.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("type=") | ||||
| 	builder.WriteString(l.Type) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("commiter=") | ||||
| 	builder.WriteString(l.Commiter) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("description=") | ||||
| 	builder.WriteString(l.Description) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // Loggings is a parsable slice of Logging. | ||||
| type Loggings []*Logging | ||||
|  | ||||
| func (l Loggings) config(cfg config) { | ||||
| 	for _i := range l { | ||||
| 		l[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										39
									
								
								ent/logging/logging.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ent/logging/logging.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package logging | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the logging type in the database. | ||||
| 	Label = "logging" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldType holds the string denoting the type field in the database. | ||||
| 	FieldType = "type" | ||||
| 	// FieldCommiter holds the string denoting the commiter field in the database. | ||||
| 	FieldCommiter = "commiter" | ||||
| 	// FieldDescription holds the string denoting the description field in the database. | ||||
| 	FieldDescription = "description" | ||||
| 	// Table holds the table name of the logging in the database. | ||||
| 	Table = "loggings" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for logging fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldType, | ||||
| 	FieldCommiter, | ||||
| 	FieldDescription, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										583
									
								
								ent/logging/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										583
									
								
								ent/logging/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,583 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package logging | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Type applies equality check predicate on the "type" field. It's identical to TypeEQ. | ||||
| func Type(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Commiter applies equality check predicate on the "commiter" field. It's identical to CommiterEQ. | ||||
| func Commiter(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. | ||||
| func Description(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEQ applies the EQ predicate on the "type" field. | ||||
| func TypeEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNEQ applies the NEQ predicate on the "type" field. | ||||
| func TypeNEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeIn applies the In predicate on the "type" field. | ||||
| func TypeIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNotIn applies the NotIn predicate on the "type" field. | ||||
| func TypeNotIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGT applies the GT predicate on the "type" field. | ||||
| func TypeGT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGTE applies the GTE predicate on the "type" field. | ||||
| func TypeGTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLT applies the LT predicate on the "type" field. | ||||
| func TypeLT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLTE applies the LTE predicate on the "type" field. | ||||
| func TypeLTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContains applies the Contains predicate on the "type" field. | ||||
| func TypeContains(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasPrefix applies the HasPrefix predicate on the "type" field. | ||||
| func TypeHasPrefix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasSuffix applies the HasSuffix predicate on the "type" field. | ||||
| func TypeHasSuffix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEqualFold applies the EqualFold predicate on the "type" field. | ||||
| func TypeEqualFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContainsFold applies the ContainsFold predicate on the "type" field. | ||||
| func TypeContainsFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterEQ applies the EQ predicate on the "commiter" field. | ||||
| func CommiterEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterNEQ applies the NEQ predicate on the "commiter" field. | ||||
| func CommiterNEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterIn applies the In predicate on the "commiter" field. | ||||
| func CommiterIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldCommiter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterNotIn applies the NotIn predicate on the "commiter" field. | ||||
| func CommiterNotIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldCommiter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterGT applies the GT predicate on the "commiter" field. | ||||
| func CommiterGT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterGTE applies the GTE predicate on the "commiter" field. | ||||
| func CommiterGTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterLT applies the LT predicate on the "commiter" field. | ||||
| func CommiterLT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterLTE applies the LTE predicate on the "commiter" field. | ||||
| func CommiterLTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterContains applies the Contains predicate on the "commiter" field. | ||||
| func CommiterContains(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterHasPrefix applies the HasPrefix predicate on the "commiter" field. | ||||
| func CommiterHasPrefix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterHasSuffix applies the HasSuffix predicate on the "commiter" field. | ||||
| func CommiterHasSuffix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterEqualFold applies the EqualFold predicate on the "commiter" field. | ||||
| func CommiterEqualFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CommiterContainsFold applies the ContainsFold predicate on the "commiter" field. | ||||
| func CommiterContainsFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldCommiter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionEQ applies the EQ predicate on the "description" field. | ||||
| func DescriptionEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionNEQ applies the NEQ predicate on the "description" field. | ||||
| func DescriptionNEQ(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionIn applies the In predicate on the "description" field. | ||||
| func DescriptionIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldDescription), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionNotIn applies the NotIn predicate on the "description" field. | ||||
| func DescriptionNotIn(vs ...string) predicate.Logging { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldDescription), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionGT applies the GT predicate on the "description" field. | ||||
| func DescriptionGT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionGTE applies the GTE predicate on the "description" field. | ||||
| func DescriptionGTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionLT applies the LT predicate on the "description" field. | ||||
| func DescriptionLT(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionLTE applies the LTE predicate on the "description" field. | ||||
| func DescriptionLTE(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionContains applies the Contains predicate on the "description" field. | ||||
| func DescriptionContains(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. | ||||
| func DescriptionHasPrefix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. | ||||
| func DescriptionHasSuffix(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionEqualFold applies the EqualFold predicate on the "description" field. | ||||
| func DescriptionEqualFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionContainsFold applies the ContainsFold predicate on the "description" field. | ||||
| func DescriptionContainsFold(v string) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Logging) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Logging) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Logging) predicate.Logging { | ||||
| 	return predicate.Logging(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										289
									
								
								ent/logging_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										289
									
								
								ent/logging_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,289 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| ) | ||||
|  | ||||
| // LoggingCreate is the builder for creating a Logging entity. | ||||
| type LoggingCreate struct { | ||||
| 	config | ||||
| 	mutation *LoggingMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (lc *LoggingCreate) SetServerid(s string) *LoggingCreate { | ||||
| 	lc.mutation.SetServerid(s) | ||||
| 	return lc | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (lc *LoggingCreate) SetType(s string) *LoggingCreate { | ||||
| 	lc.mutation.SetType(s) | ||||
| 	return lc | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (lc *LoggingCreate) SetCommiter(s string) *LoggingCreate { | ||||
| 	lc.mutation.SetCommiter(s) | ||||
| 	return lc | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (lc *LoggingCreate) SetDescription(s string) *LoggingCreate { | ||||
| 	lc.mutation.SetDescription(s) | ||||
| 	return lc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (lc *LoggingCreate) SetID(i int) *LoggingCreate { | ||||
| 	lc.mutation.SetID(i) | ||||
| 	return lc | ||||
| } | ||||
|  | ||||
| // Mutation returns the LoggingMutation object of the builder. | ||||
| func (lc *LoggingCreate) Mutation() *LoggingMutation { | ||||
| 	return lc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Logging in the database. | ||||
| func (lc *LoggingCreate) Save(ctx context.Context) (*Logging, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Logging | ||||
| 	) | ||||
| 	if len(lc.hooks) == 0 { | ||||
| 		if err = lc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = lc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*LoggingMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = lc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			lc.mutation = mutation | ||||
| 			if node, err = lc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(lc.hooks) - 1; i >= 0; i-- { | ||||
| 			if lc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = lc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, lc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Logging) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from LoggingMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (lc *LoggingCreate) SaveX(ctx context.Context) *Logging { | ||||
| 	v, err := lc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (lc *LoggingCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := lc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (lc *LoggingCreate) ExecX(ctx context.Context) { | ||||
| 	if err := lc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (lc *LoggingCreate) check() error { | ||||
| 	if _, ok := lc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Logging.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := lc.mutation.GetType(); !ok { | ||||
| 		return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Logging.type"`)} | ||||
| 	} | ||||
| 	if _, ok := lc.mutation.Commiter(); !ok { | ||||
| 		return &ValidationError{Name: "commiter", err: errors.New(`ent: missing required field "Logging.commiter"`)} | ||||
| 	} | ||||
| 	if _, ok := lc.mutation.Description(); !ok { | ||||
| 		return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Logging.description"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (lc *LoggingCreate) sqlSave(ctx context.Context) (*Logging, error) { | ||||
| 	_node, _spec := lc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, lc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (lc *LoggingCreate) createSpec() (*Logging, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Logging{config: lc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: logging.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: logging.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := lc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := lc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := lc.mutation.GetType(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldType, | ||||
| 		}) | ||||
| 		_node.Type = value | ||||
| 	} | ||||
| 	if value, ok := lc.mutation.Commiter(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldCommiter, | ||||
| 		}) | ||||
| 		_node.Commiter = value | ||||
| 	} | ||||
| 	if value, ok := lc.mutation.Description(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldDescription, | ||||
| 		}) | ||||
| 		_node.Description = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // LoggingCreateBulk is the builder for creating many Logging entities in bulk. | ||||
| type LoggingCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*LoggingCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Logging entities in the database. | ||||
| func (lcb *LoggingCreateBulk) Save(ctx context.Context) ([]*Logging, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(lcb.builders)) | ||||
| 	nodes := make([]*Logging, len(lcb.builders)) | ||||
| 	mutators := make([]Mutator, len(lcb.builders)) | ||||
| 	for i := range lcb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := lcb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*LoggingMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, lcb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, lcb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, lcb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (lcb *LoggingCreateBulk) SaveX(ctx context.Context) []*Logging { | ||||
| 	v, err := lcb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (lcb *LoggingCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := lcb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (lcb *LoggingCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := lcb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/logging_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/logging_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // LoggingDelete is the builder for deleting a Logging entity. | ||||
| type LoggingDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *LoggingMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the LoggingDelete builder. | ||||
| func (ld *LoggingDelete) Where(ps ...predicate.Logging) *LoggingDelete { | ||||
| 	ld.mutation.Where(ps...) | ||||
| 	return ld | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (ld *LoggingDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(ld.hooks) == 0 { | ||||
| 		affected, err = ld.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*LoggingMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			ld.mutation = mutation | ||||
| 			affected, err = ld.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(ld.hooks) - 1; i >= 0; i-- { | ||||
| 			if ld.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = ld.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, ld.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ld *LoggingDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := ld.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (ld *LoggingDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: logging.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: logging.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := ld.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, ld.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // LoggingDeleteOne is the builder for deleting a single Logging entity. | ||||
| type LoggingDeleteOne struct { | ||||
| 	ld *LoggingDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (ldo *LoggingDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := ldo.ld.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{logging.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (ldo *LoggingDeleteOne) ExecX(ctx context.Context) { | ||||
| 	ldo.ld.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/logging_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/logging_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // LoggingQuery is the builder for querying Logging entities. | ||||
| type LoggingQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Logging | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the LoggingQuery builder. | ||||
| func (lq *LoggingQuery) Where(ps ...predicate.Logging) *LoggingQuery { | ||||
| 	lq.predicates = append(lq.predicates, ps...) | ||||
| 	return lq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (lq *LoggingQuery) Limit(limit int) *LoggingQuery { | ||||
| 	lq.limit = &limit | ||||
| 	return lq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (lq *LoggingQuery) Offset(offset int) *LoggingQuery { | ||||
| 	lq.offset = &offset | ||||
| 	return lq | ||||
| } | ||||
|  | ||||
| // 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 (lq *LoggingQuery) Unique(unique bool) *LoggingQuery { | ||||
| 	lq.unique = &unique | ||||
| 	return lq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (lq *LoggingQuery) Order(o ...OrderFunc) *LoggingQuery { | ||||
| 	lq.order = append(lq.order, o...) | ||||
| 	return lq | ||||
| } | ||||
|  | ||||
| // First returns the first Logging entity from the query. | ||||
| // Returns a *NotFoundError when no Logging was found. | ||||
| func (lq *LoggingQuery) First(ctx context.Context) (*Logging, error) { | ||||
| 	nodes, err := lq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{logging.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) FirstX(ctx context.Context) *Logging { | ||||
| 	node, err := lq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Logging ID from the query. | ||||
| // Returns a *NotFoundError when no Logging ID was found. | ||||
| func (lq *LoggingQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = lq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{logging.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := lq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Logging entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Logging entity is found. | ||||
| // Returns a *NotFoundError when no Logging entities are found. | ||||
| func (lq *LoggingQuery) Only(ctx context.Context) (*Logging, error) { | ||||
| 	nodes, err := lq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{logging.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{logging.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) OnlyX(ctx context.Context) *Logging { | ||||
| 	node, err := lq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Logging ID in the query. | ||||
| // Returns a *NotSingularError when more than one Logging ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (lq *LoggingQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = lq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{logging.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{logging.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := lq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of Loggings. | ||||
| func (lq *LoggingQuery) All(ctx context.Context) ([]*Logging, error) { | ||||
| 	if err := lq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return lq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) AllX(ctx context.Context) []*Logging { | ||||
| 	nodes, err := lq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Logging IDs. | ||||
| func (lq *LoggingQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := lq.Select(logging.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := lq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (lq *LoggingQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := lq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return lq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := lq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (lq *LoggingQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := lq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return lq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (lq *LoggingQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := lq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the LoggingQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (lq *LoggingQuery) Clone() *LoggingQuery { | ||||
| 	if lq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &LoggingQuery{ | ||||
| 		config:     lq.config, | ||||
| 		limit:      lq.limit, | ||||
| 		offset:     lq.offset, | ||||
| 		order:      append([]OrderFunc{}, lq.order...), | ||||
| 		predicates: append([]predicate.Logging{}, lq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    lq.sql.Clone(), | ||||
| 		path:   lq.path, | ||||
| 		unique: lq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Logging.Query(). | ||||
| //		GroupBy(logging.FieldServerid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (lq *LoggingQuery) GroupBy(field string, fields ...string) *LoggingGroupBy { | ||||
| 	grbuild := &LoggingGroupBy{config: lq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := lq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return lq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = logging.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Logging.Query(). | ||||
| //		Select(logging.FieldServerid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (lq *LoggingQuery) Select(fields ...string) *LoggingSelect { | ||||
| 	lq.fields = append(lq.fields, fields...) | ||||
| 	selbuild := &LoggingSelect{LoggingQuery: lq} | ||||
| 	selbuild.label = logging.Label | ||||
| 	selbuild.flds, selbuild.scan = &lq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range lq.fields { | ||||
| 		if !logging.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if lq.path != nil { | ||||
| 		prev, err := lq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		lq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Logging, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Logging{} | ||||
| 		_spec = lq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Logging).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Logging{config: lq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, lq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := lq.querySpec() | ||||
| 	_spec.Node.Columns = lq.fields | ||||
| 	if len(lq.fields) > 0 { | ||||
| 		_spec.Unique = lq.unique != nil && *lq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, lq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := lq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   logging.Table, | ||||
| 			Columns: logging.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: logging.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   lq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := lq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := lq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, logging.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != logging.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := lq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := lq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := lq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := lq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (lq *LoggingQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(lq.driver.Dialect()) | ||||
| 	t1 := builder.Table(logging.Table) | ||||
| 	columns := lq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = logging.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if lq.sql != nil { | ||||
| 		selector = lq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if lq.unique != nil && *lq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range lq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range lq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := lq.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 := lq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // LoggingGroupBy is the group-by builder for Logging entities. | ||||
| type LoggingGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (lgb *LoggingGroupBy) Aggregate(fns ...AggregateFunc) *LoggingGroupBy { | ||||
| 	lgb.fns = append(lgb.fns, fns...) | ||||
| 	return lgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (lgb *LoggingGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := lgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	lgb.sql = query | ||||
| 	return lgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (lgb *LoggingGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range lgb.fields { | ||||
| 		if !logging.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := lgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := lgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (lgb *LoggingGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := lgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(lgb.fns)) | ||||
| 	for _, fn := range lgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(lgb.fields)+len(lgb.fns)) | ||||
| 		for _, f := range lgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(lgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // LoggingSelect is the builder for selecting fields of Logging entities. | ||||
| type LoggingSelect struct { | ||||
| 	*LoggingQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ls *LoggingSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ls.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ls.sql = ls.LoggingQuery.sqlQuery(ctx) | ||||
| 	return ls.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ls *LoggingSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ls.sql.Query() | ||||
| 	if err := ls.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										349
									
								
								ent/logging_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										349
									
								
								ent/logging_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,349 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/logging" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // LoggingUpdate is the builder for updating Logging entities. | ||||
| type LoggingUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *LoggingMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the LoggingUpdate builder. | ||||
| func (lu *LoggingUpdate) Where(ps ...predicate.Logging) *LoggingUpdate { | ||||
| 	lu.mutation.Where(ps...) | ||||
| 	return lu | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (lu *LoggingUpdate) SetServerid(s string) *LoggingUpdate { | ||||
| 	lu.mutation.SetServerid(s) | ||||
| 	return lu | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (lu *LoggingUpdate) SetType(s string) *LoggingUpdate { | ||||
| 	lu.mutation.SetType(s) | ||||
| 	return lu | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (lu *LoggingUpdate) SetCommiter(s string) *LoggingUpdate { | ||||
| 	lu.mutation.SetCommiter(s) | ||||
| 	return lu | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (lu *LoggingUpdate) SetDescription(s string) *LoggingUpdate { | ||||
| 	lu.mutation.SetDescription(s) | ||||
| 	return lu | ||||
| } | ||||
|  | ||||
| // Mutation returns the LoggingMutation object of the builder. | ||||
| func (lu *LoggingUpdate) Mutation() *LoggingMutation { | ||||
| 	return lu.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (lu *LoggingUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(lu.hooks) == 0 { | ||||
| 		affected, err = lu.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*LoggingMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			lu.mutation = mutation | ||||
| 			affected, err = lu.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(lu.hooks) - 1; i >= 0; i-- { | ||||
| 			if lu.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = lu.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, lu.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (lu *LoggingUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := lu.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (lu *LoggingUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := lu.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (lu *LoggingUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := lu.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (lu *LoggingUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   logging.Table, | ||||
| 			Columns: logging.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: logging.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := lu.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := lu.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := lu.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := lu.mutation.Commiter(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldCommiter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := lu.mutation.Description(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldDescription, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, lu.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{logging.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // LoggingUpdateOne is the builder for updating a single Logging entity. | ||||
| type LoggingUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *LoggingMutation | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (luo *LoggingUpdateOne) SetServerid(s string) *LoggingUpdateOne { | ||||
| 	luo.mutation.SetServerid(s) | ||||
| 	return luo | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (luo *LoggingUpdateOne) SetType(s string) *LoggingUpdateOne { | ||||
| 	luo.mutation.SetType(s) | ||||
| 	return luo | ||||
| } | ||||
|  | ||||
| // SetCommiter sets the "commiter" field. | ||||
| func (luo *LoggingUpdateOne) SetCommiter(s string) *LoggingUpdateOne { | ||||
| 	luo.mutation.SetCommiter(s) | ||||
| 	return luo | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (luo *LoggingUpdateOne) SetDescription(s string) *LoggingUpdateOne { | ||||
| 	luo.mutation.SetDescription(s) | ||||
| 	return luo | ||||
| } | ||||
|  | ||||
| // Mutation returns the LoggingMutation object of the builder. | ||||
| func (luo *LoggingUpdateOne) Mutation() *LoggingMutation { | ||||
| 	return luo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (luo *LoggingUpdateOne) Select(field string, fields ...string) *LoggingUpdateOne { | ||||
| 	luo.fields = append([]string{field}, fields...) | ||||
| 	return luo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Logging entity. | ||||
| func (luo *LoggingUpdateOne) Save(ctx context.Context) (*Logging, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Logging | ||||
| 	) | ||||
| 	if len(luo.hooks) == 0 { | ||||
| 		node, err = luo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*LoggingMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			luo.mutation = mutation | ||||
| 			node, err = luo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(luo.hooks) - 1; i >= 0; i-- { | ||||
| 			if luo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = luo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, luo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Logging) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from LoggingMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (luo *LoggingUpdateOne) SaveX(ctx context.Context) *Logging { | ||||
| 	node, err := luo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (luo *LoggingUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := luo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (luo *LoggingUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := luo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (luo *LoggingUpdateOne) sqlSave(ctx context.Context) (_node *Logging, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   logging.Table, | ||||
| 			Columns: logging.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: logging.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := luo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Logging.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := luo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, logging.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !logging.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != logging.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := luo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := luo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := luo.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := luo.mutation.Commiter(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldCommiter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := luo.mutation.Description(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: logging.FieldDescription, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Logging{config: luo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, luo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{logging.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										65
									
								
								ent/migrate/migrate.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								ent/migrate/migrate.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,65 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package migrate | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
|  | ||||
| 	"entgo.io/ent/dialect" | ||||
| 	"entgo.io/ent/dialect/sql/schema" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// WithGlobalUniqueID sets the universal ids options to the migration. | ||||
| 	// If this option is enabled, ent migration will allocate a 1<<32 range | ||||
| 	// for the ids of each entity (table). | ||||
| 	// Note that this option cannot be applied on tables that already exist. | ||||
| 	WithGlobalUniqueID = schema.WithGlobalUniqueID | ||||
| 	// WithDropColumn sets the drop column option to the migration. | ||||
| 	// If this option is enabled, ent migration will drop old columns | ||||
| 	// that were used for both fields and edges. This defaults to false. | ||||
| 	WithDropColumn = schema.WithDropColumn | ||||
| 	// WithDropIndex sets the drop index option to the migration. | ||||
| 	// If this option is enabled, ent migration will drop old indexes | ||||
| 	// that were defined in the schema. This defaults to false. | ||||
| 	// Note that unique constraints are defined using `UNIQUE INDEX`, | ||||
| 	// and therefore, it's recommended to enable this option to get more | ||||
| 	// flexibility in the schema changes. | ||||
| 	WithDropIndex = schema.WithDropIndex | ||||
| 	// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true. | ||||
| 	WithForeignKeys = schema.WithForeignKeys | ||||
| ) | ||||
|  | ||||
| // Schema is the API for creating, migrating and dropping a schema. | ||||
| type Schema struct { | ||||
| 	drv dialect.Driver | ||||
| } | ||||
|  | ||||
| // NewSchema creates a new schema client. | ||||
| func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} } | ||||
|  | ||||
| // Create creates all schema resources. | ||||
| func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error { | ||||
| 	return Create(ctx, s, Tables, opts...) | ||||
| } | ||||
|  | ||||
| // Create creates all table resources using the given schema driver. | ||||
| func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error { | ||||
| 	migrate, err := schema.NewMigrate(s.drv, opts...) | ||||
| 	if err != nil { | ||||
| 		return fmt.Errorf("ent/migrate: %w", err) | ||||
| 	} | ||||
| 	return migrate.Create(ctx, tables...) | ||||
| } | ||||
|  | ||||
| // WriteTo writes the schema changes to w instead of running them against the database. | ||||
| // | ||||
| // 	if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil { | ||||
| //		log.Fatal(err) | ||||
| // 	} | ||||
| // | ||||
| func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error { | ||||
| 	return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...) | ||||
| } | ||||
							
								
								
									
										231
									
								
								ent/migrate/schema.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								ent/migrate/schema.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,231 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package migrate | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql/schema" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// ActionsColumns holds the columns for the "actions" table. | ||||
| 	ActionsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "refid", Type: field.TypeString}, | ||||
| 		{Name: "commiter", Type: field.TypeString}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "target", Type: field.TypeString}, | ||||
| 		{Name: "type", Type: field.TypeString}, | ||||
| 		{Name: "duration", Type: field.TypeString}, | ||||
| 		{Name: "reason", Type: field.TypeString}, | ||||
| 		{Name: "temp", Type: field.TypeBool, Default: false}, | ||||
| 	} | ||||
| 	// ActionsTable holds the schema information for the "actions" table. | ||||
| 	ActionsTable = &schema.Table{ | ||||
| 		Name:       "actions", | ||||
| 		Columns:    ActionsColumns, | ||||
| 		PrimaryKey: []*schema.Column{ActionsColumns[0]}, | ||||
| 	} | ||||
| 	// AuthorizablesColumns holds the columns for the "authorizables" table. | ||||
| 	AuthorizablesColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "username", Type: field.TypeString}, | ||||
| 		{Name: "password", Type: field.TypeString}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "userid", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// AuthorizablesTable holds the schema information for the "authorizables" table. | ||||
| 	AuthorizablesTable = &schema.Table{ | ||||
| 		Name:       "authorizables", | ||||
| 		Columns:    AuthorizablesColumns, | ||||
| 		PrimaryKey: []*schema.Column{AuthorizablesColumns[0]}, | ||||
| 	} | ||||
| 	// BlacklistsColumns holds the columns for the "blacklists" table. | ||||
| 	BlacklistsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "word", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// BlacklistsTable holds the schema information for the "blacklists" table. | ||||
| 	BlacklistsTable = &schema.Table{ | ||||
| 		Name:       "blacklists", | ||||
| 		Columns:    BlacklistsColumns, | ||||
| 		PrimaryKey: []*schema.Column{BlacklistsColumns[0]}, | ||||
| 	} | ||||
| 	// LoggingsColumns holds the columns for the "loggings" table. | ||||
| 	LoggingsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "type", Type: field.TypeString}, | ||||
| 		{Name: "commiter", Type: field.TypeString}, | ||||
| 		{Name: "description", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// LoggingsTable holds the schema information for the "loggings" table. | ||||
| 	LoggingsTable = &schema.Table{ | ||||
| 		Name:       "loggings", | ||||
| 		Columns:    LoggingsColumns, | ||||
| 		PrimaryKey: []*schema.Column{LoggingsColumns[0]}, | ||||
| 	} | ||||
| 	// PunishmentsColumns holds the columns for the "punishments" table. | ||||
| 	PunishmentsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "warnamount", Type: field.TypeString}, | ||||
| 		{Name: "actiontype", Type: field.TypeString}, | ||||
| 		{Name: "duration", Type: field.TypeString}, | ||||
| 		{Name: "reason", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// PunishmentsTable holds the schema information for the "punishments" table. | ||||
| 	PunishmentsTable = &schema.Table{ | ||||
| 		Name:       "punishments", | ||||
| 		Columns:    PunishmentsColumns, | ||||
| 		PrimaryKey: []*schema.Column{PunishmentsColumns[0]}, | ||||
| 	} | ||||
| 	// ServersColumns holds the columns for the "servers" table. | ||||
| 	ServersColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "userid", Type: field.TypeString}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "is_owner", Type: field.TypeBool}, | ||||
| 		{Name: "permission", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// ServersTable holds the schema information for the "servers" table. | ||||
| 	ServersTable = &schema.Table{ | ||||
| 		Name:       "servers", | ||||
| 		Columns:    ServersColumns, | ||||
| 		PrimaryKey: []*schema.Column{ServersColumns[0]}, | ||||
| 	} | ||||
| 	// SettingsColumns holds the columns for the "settings" table. | ||||
| 	SettingsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "servername", Type: field.TypeString}, | ||||
| 		{Name: "ownerid", Type: field.TypeString}, | ||||
| 		{Name: "permtoken", Type: field.TypeString}, | ||||
| 		{Name: "apitoken", Type: field.TypeString}, | ||||
| 		{Name: "statspagemode", Type: field.TypeString}, | ||||
| 		{Name: "loggerchannel", Type: field.TypeString}, | ||||
| 		{Name: "spamchannel", Type: field.TypeString}, | ||||
| 		{Name: "greeterchannel", Type: field.TypeString}, | ||||
| 		{Name: "greetermode", Type: field.TypeString}, | ||||
| 		{Name: "announcechannel", Type: field.TypeString}, | ||||
| 		{Name: "logger", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "spamprotection", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "linkprotection", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "wordfilter", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "greetings", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "apitoggle", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "moderation", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "automatedmoderation", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "twitchannounce", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "twitterannounce", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "music", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "statspage", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "statsprivate", Type: field.TypeBool, Default: false}, | ||||
| 		{Name: "stats", Type: field.TypeBool, Default: false}, | ||||
| 	} | ||||
| 	// SettingsTable holds the schema information for the "settings" table. | ||||
| 	SettingsTable = &schema.Table{ | ||||
| 		Name:       "settings", | ||||
| 		Columns:    SettingsColumns, | ||||
| 		PrimaryKey: []*schema.Column{SettingsColumns[0]}, | ||||
| 	} | ||||
| 	// SocialmediaColumns holds the columns for the "socialmedia" table. | ||||
| 	SocialmediaColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "type", Type: field.TypeString}, | ||||
| 		{Name: "identificator", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// SocialmediaTable holds the schema information for the "socialmedia" table. | ||||
| 	SocialmediaTable = &schema.Table{ | ||||
| 		Name:       "socialmedia", | ||||
| 		Columns:    SocialmediaColumns, | ||||
| 		PrimaryKey: []*schema.Column{SocialmediaColumns[0]}, | ||||
| 	} | ||||
| 	// SupportsColumns holds the columns for the "supports" table. | ||||
| 	SupportsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "refid", Type: field.TypeString}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "creator", Type: field.TypeString}, | ||||
| 		{Name: "status", Type: field.TypeString}, | ||||
| 		{Name: "title", Type: field.TypeString}, | ||||
| 		{Name: "description", Type: field.TypeString}, | ||||
| 	} | ||||
| 	// SupportsTable holds the schema information for the "supports" table. | ||||
| 	SupportsTable = &schema.Table{ | ||||
| 		Name:       "supports", | ||||
| 		Columns:    SupportsColumns, | ||||
| 		PrimaryKey: []*schema.Column{SupportsColumns[0]}, | ||||
| 	} | ||||
| 	// SupportResponsesColumns holds the columns for the "support_responses" table. | ||||
| 	SupportResponsesColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "refid", Type: field.TypeString}, | ||||
| 		{Name: "writer", Type: field.TypeString}, | ||||
| 		{Name: "message", Type: field.TypeString}, | ||||
| 		{Name: "type", Type: field.TypeString}, | ||||
| 		{Name: "rtcchannel", Type: field.TypeString}, | ||||
| 		{Name: "isread", Type: field.TypeBool}, | ||||
| 		{Name: "created", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"}, | ||||
| 	} | ||||
| 	// SupportResponsesTable holds the schema information for the "support_responses" table. | ||||
| 	SupportResponsesTable = &schema.Table{ | ||||
| 		Name:       "support_responses", | ||||
| 		Columns:    SupportResponsesColumns, | ||||
| 		PrimaryKey: []*schema.Column{SupportResponsesColumns[0]}, | ||||
| 	} | ||||
| 	// UsersColumns holds the columns for the "users" table. | ||||
| 	UsersColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "userid", Type: field.TypeString}, | ||||
| 		{Name: "username", Type: field.TypeString}, | ||||
| 		{Name: "xp", Type: field.TypeInt, Default: 0}, | ||||
| 		{Name: "level", Type: field.TypeInt, Default: 1}, | ||||
| 		{Name: "msgs", Type: field.TypeInt, Default: 0}, | ||||
| 		{Name: "created", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"}, | ||||
| 	} | ||||
| 	// UsersTable holds the schema information for the "users" table. | ||||
| 	UsersTable = &schema.Table{ | ||||
| 		Name:       "users", | ||||
| 		Columns:    UsersColumns, | ||||
| 		PrimaryKey: []*schema.Column{UsersColumns[0]}, | ||||
| 	} | ||||
| 	// WarnsColumns holds the columns for the "warns" table. | ||||
| 	WarnsColumns = []*schema.Column{ | ||||
| 		{Name: "id", Type: field.TypeInt, Increment: true}, | ||||
| 		{Name: "emitter", Type: field.TypeString}, | ||||
| 		{Name: "serverid", Type: field.TypeString}, | ||||
| 		{Name: "target", Type: field.TypeString}, | ||||
| 		{Name: "type", Type: field.TypeString}, | ||||
| 		{Name: "duration", Type: field.TypeString}, | ||||
| 		{Name: "reason", Type: field.TypeString}, | ||||
| 		{Name: "refid", Type: field.TypeString, Unique: true}, | ||||
| 	} | ||||
| 	// WarnsTable holds the schema information for the "warns" table. | ||||
| 	WarnsTable = &schema.Table{ | ||||
| 		Name:       "warns", | ||||
| 		Columns:    WarnsColumns, | ||||
| 		PrimaryKey: []*schema.Column{WarnsColumns[0]}, | ||||
| 	} | ||||
| 	// Tables holds all the tables in the schema. | ||||
| 	Tables = []*schema.Table{ | ||||
| 		ActionsTable, | ||||
| 		AuthorizablesTable, | ||||
| 		BlacklistsTable, | ||||
| 		LoggingsTable, | ||||
| 		PunishmentsTable, | ||||
| 		ServersTable, | ||||
| 		SettingsTable, | ||||
| 		SocialmediaTable, | ||||
| 		SupportsTable, | ||||
| 		SupportResponsesTable, | ||||
| 		UsersTable, | ||||
| 		WarnsTable, | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| } | ||||
							
								
								
									
										7730
									
								
								ent/mutation.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7730
									
								
								ent/mutation.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										43
									
								
								ent/predicate/predicate.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								ent/predicate/predicate.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package predicate | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| ) | ||||
|  | ||||
| // Actions is the predicate function for actions builders. | ||||
| type Actions func(*sql.Selector) | ||||
|  | ||||
| // Authorizables is the predicate function for authorizables builders. | ||||
| type Authorizables func(*sql.Selector) | ||||
|  | ||||
| // Blacklist is the predicate function for blacklist builders. | ||||
| type Blacklist func(*sql.Selector) | ||||
|  | ||||
| // Logging is the predicate function for logging builders. | ||||
| type Logging func(*sql.Selector) | ||||
|  | ||||
| // Punishments is the predicate function for punishments builders. | ||||
| type Punishments func(*sql.Selector) | ||||
|  | ||||
| // Servers is the predicate function for servers builders. | ||||
| type Servers func(*sql.Selector) | ||||
|  | ||||
| // Settings is the predicate function for settings builders. | ||||
| type Settings func(*sql.Selector) | ||||
|  | ||||
| // Socialmedia is the predicate function for socialmedia builders. | ||||
| type Socialmedia func(*sql.Selector) | ||||
|  | ||||
| // Support is the predicate function for support builders. | ||||
| type Support func(*sql.Selector) | ||||
|  | ||||
| // SupportResponse is the predicate function for supportresponse builders. | ||||
| type SupportResponse func(*sql.Selector) | ||||
|  | ||||
| // User is the predicate function for user builders. | ||||
| type User func(*sql.Selector) | ||||
|  | ||||
| // Warns is the predicate function for warns builders. | ||||
| type Warns func(*sql.Selector) | ||||
							
								
								
									
										143
									
								
								ent/punishments.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										143
									
								
								ent/punishments.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,143 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| ) | ||||
|  | ||||
| // Punishments is the model entity for the Punishments schema. | ||||
| type Punishments struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Warnamount holds the value of the "warnamount" field. | ||||
| 	Warnamount string `json:"warnamount,omitempty"` | ||||
| 	// Actiontype holds the value of the "actiontype" field. | ||||
| 	Actiontype string `json:"actiontype,omitempty"` | ||||
| 	// Duration holds the value of the "duration" field. | ||||
| 	Duration string `json:"duration,omitempty"` | ||||
| 	// Reason holds the value of the "reason" field. | ||||
| 	Reason string `json:"reason,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Punishments) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case punishments.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case punishments.FieldServerid, punishments.FieldWarnamount, punishments.FieldActiontype, punishments.FieldDuration, punishments.FieldReason: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Punishments", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Punishments fields. | ||||
| func (pu *Punishments) assignValues(columns []string, values []interface{}) 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 punishments.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			pu.ID = int(value.Int64) | ||||
| 		case punishments.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				pu.Serverid = value.String | ||||
| 			} | ||||
| 		case punishments.FieldWarnamount: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field warnamount", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				pu.Warnamount = value.String | ||||
| 			} | ||||
| 		case punishments.FieldActiontype: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field actiontype", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				pu.Actiontype = value.String | ||||
| 			} | ||||
| 		case punishments.FieldDuration: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field duration", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				pu.Duration = value.String | ||||
| 			} | ||||
| 		case punishments.FieldReason: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field reason", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				pu.Reason = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Punishments. | ||||
| // Note that you need to call Punishments.Unwrap() before calling this method if this Punishments | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (pu *Punishments) Update() *PunishmentsUpdateOne { | ||||
| 	return (&PunishmentsClient{config: pu.config}).UpdateOne(pu) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Punishments 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 (pu *Punishments) Unwrap() *Punishments { | ||||
| 	_tx, ok := pu.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Punishments is not a transactional entity") | ||||
| 	} | ||||
| 	pu.config.driver = _tx.drv | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (pu *Punishments) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Punishments(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", pu.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(pu.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("warnamount=") | ||||
| 	builder.WriteString(pu.Warnamount) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("actiontype=") | ||||
| 	builder.WriteString(pu.Actiontype) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("duration=") | ||||
| 	builder.WriteString(pu.Duration) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("reason=") | ||||
| 	builder.WriteString(pu.Reason) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // PunishmentsSlice is a parsable slice of Punishments. | ||||
| type PunishmentsSlice []*Punishments | ||||
|  | ||||
| func (pu PunishmentsSlice) config(cfg config) { | ||||
| 	for _i := range pu { | ||||
| 		pu[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										42
									
								
								ent/punishments/punishments.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								ent/punishments/punishments.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,42 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package punishments | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the punishments type in the database. | ||||
| 	Label = "punishments" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldWarnamount holds the string denoting the warnamount field in the database. | ||||
| 	FieldWarnamount = "warnamount" | ||||
| 	// FieldActiontype holds the string denoting the actiontype field in the database. | ||||
| 	FieldActiontype = "actiontype" | ||||
| 	// FieldDuration holds the string denoting the duration field in the database. | ||||
| 	FieldDuration = "duration" | ||||
| 	// FieldReason holds the string denoting the reason field in the database. | ||||
| 	FieldReason = "reason" | ||||
| 	// Table holds the table name of the punishments in the database. | ||||
| 	Table = "punishments" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for punishments fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldWarnamount, | ||||
| 	FieldActiontype, | ||||
| 	FieldDuration, | ||||
| 	FieldReason, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										701
									
								
								ent/punishments/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										701
									
								
								ent/punishments/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,701 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package punishments | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Warnamount applies equality check predicate on the "warnamount" field. It's identical to WarnamountEQ. | ||||
| func Warnamount(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Actiontype applies equality check predicate on the "actiontype" field. It's identical to ActiontypeEQ. | ||||
| func Actiontype(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Duration applies equality check predicate on the "duration" field. It's identical to DurationEQ. | ||||
| func Duration(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Reason applies equality check predicate on the "reason" field. It's identical to ReasonEQ. | ||||
| func Reason(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountEQ applies the EQ predicate on the "warnamount" field. | ||||
| func WarnamountEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountNEQ applies the NEQ predicate on the "warnamount" field. | ||||
| func WarnamountNEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountIn applies the In predicate on the "warnamount" field. | ||||
| func WarnamountIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldWarnamount), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountNotIn applies the NotIn predicate on the "warnamount" field. | ||||
| func WarnamountNotIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldWarnamount), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountGT applies the GT predicate on the "warnamount" field. | ||||
| func WarnamountGT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountGTE applies the GTE predicate on the "warnamount" field. | ||||
| func WarnamountGTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountLT applies the LT predicate on the "warnamount" field. | ||||
| func WarnamountLT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountLTE applies the LTE predicate on the "warnamount" field. | ||||
| func WarnamountLTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountContains applies the Contains predicate on the "warnamount" field. | ||||
| func WarnamountContains(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountHasPrefix applies the HasPrefix predicate on the "warnamount" field. | ||||
| func WarnamountHasPrefix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountHasSuffix applies the HasSuffix predicate on the "warnamount" field. | ||||
| func WarnamountHasSuffix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountEqualFold applies the EqualFold predicate on the "warnamount" field. | ||||
| func WarnamountEqualFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WarnamountContainsFold applies the ContainsFold predicate on the "warnamount" field. | ||||
| func WarnamountContainsFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldWarnamount), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeEQ applies the EQ predicate on the "actiontype" field. | ||||
| func ActiontypeEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeNEQ applies the NEQ predicate on the "actiontype" field. | ||||
| func ActiontypeNEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeIn applies the In predicate on the "actiontype" field. | ||||
| func ActiontypeIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldActiontype), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeNotIn applies the NotIn predicate on the "actiontype" field. | ||||
| func ActiontypeNotIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldActiontype), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeGT applies the GT predicate on the "actiontype" field. | ||||
| func ActiontypeGT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeGTE applies the GTE predicate on the "actiontype" field. | ||||
| func ActiontypeGTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeLT applies the LT predicate on the "actiontype" field. | ||||
| func ActiontypeLT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeLTE applies the LTE predicate on the "actiontype" field. | ||||
| func ActiontypeLTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeContains applies the Contains predicate on the "actiontype" field. | ||||
| func ActiontypeContains(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeHasPrefix applies the HasPrefix predicate on the "actiontype" field. | ||||
| func ActiontypeHasPrefix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeHasSuffix applies the HasSuffix predicate on the "actiontype" field. | ||||
| func ActiontypeHasSuffix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeEqualFold applies the EqualFold predicate on the "actiontype" field. | ||||
| func ActiontypeEqualFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ActiontypeContainsFold applies the ContainsFold predicate on the "actiontype" field. | ||||
| func ActiontypeContainsFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldActiontype), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationEQ applies the EQ predicate on the "duration" field. | ||||
| func DurationEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationNEQ applies the NEQ predicate on the "duration" field. | ||||
| func DurationNEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationIn applies the In predicate on the "duration" field. | ||||
| func DurationIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldDuration), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationNotIn applies the NotIn predicate on the "duration" field. | ||||
| func DurationNotIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldDuration), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationGT applies the GT predicate on the "duration" field. | ||||
| func DurationGT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationGTE applies the GTE predicate on the "duration" field. | ||||
| func DurationGTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationLT applies the LT predicate on the "duration" field. | ||||
| func DurationLT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationLTE applies the LTE predicate on the "duration" field. | ||||
| func DurationLTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationContains applies the Contains predicate on the "duration" field. | ||||
| func DurationContains(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationHasPrefix applies the HasPrefix predicate on the "duration" field. | ||||
| func DurationHasPrefix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationHasSuffix applies the HasSuffix predicate on the "duration" field. | ||||
| func DurationHasSuffix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationEqualFold applies the EqualFold predicate on the "duration" field. | ||||
| func DurationEqualFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DurationContainsFold applies the ContainsFold predicate on the "duration" field. | ||||
| func DurationContainsFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldDuration), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonEQ applies the EQ predicate on the "reason" field. | ||||
| func ReasonEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonNEQ applies the NEQ predicate on the "reason" field. | ||||
| func ReasonNEQ(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonIn applies the In predicate on the "reason" field. | ||||
| func ReasonIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldReason), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonNotIn applies the NotIn predicate on the "reason" field. | ||||
| func ReasonNotIn(vs ...string) predicate.Punishments { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldReason), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonGT applies the GT predicate on the "reason" field. | ||||
| func ReasonGT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonGTE applies the GTE predicate on the "reason" field. | ||||
| func ReasonGTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonLT applies the LT predicate on the "reason" field. | ||||
| func ReasonLT(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonLTE applies the LTE predicate on the "reason" field. | ||||
| func ReasonLTE(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonContains applies the Contains predicate on the "reason" field. | ||||
| func ReasonContains(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonHasPrefix applies the HasPrefix predicate on the "reason" field. | ||||
| func ReasonHasPrefix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonHasSuffix applies the HasSuffix predicate on the "reason" field. | ||||
| func ReasonHasSuffix(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonEqualFold applies the EqualFold predicate on the "reason" field. | ||||
| func ReasonEqualFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ReasonContainsFold applies the ContainsFold predicate on the "reason" field. | ||||
| func ReasonContainsFold(v string) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldReason), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Punishments) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Punishments) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Punishments) predicate.Punishments { | ||||
| 	return predicate.Punishments(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										306
									
								
								ent/punishments_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										306
									
								
								ent/punishments_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,306 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| ) | ||||
|  | ||||
| // PunishmentsCreate is the builder for creating a Punishments entity. | ||||
| type PunishmentsCreate struct { | ||||
| 	config | ||||
| 	mutation *PunishmentsMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (pc *PunishmentsCreate) SetServerid(s string) *PunishmentsCreate { | ||||
| 	pc.mutation.SetServerid(s) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // SetWarnamount sets the "warnamount" field. | ||||
| func (pc *PunishmentsCreate) SetWarnamount(s string) *PunishmentsCreate { | ||||
| 	pc.mutation.SetWarnamount(s) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // SetActiontype sets the "actiontype" field. | ||||
| func (pc *PunishmentsCreate) SetActiontype(s string) *PunishmentsCreate { | ||||
| 	pc.mutation.SetActiontype(s) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (pc *PunishmentsCreate) SetDuration(s string) *PunishmentsCreate { | ||||
| 	pc.mutation.SetDuration(s) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (pc *PunishmentsCreate) SetReason(s string) *PunishmentsCreate { | ||||
| 	pc.mutation.SetReason(s) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (pc *PunishmentsCreate) SetID(i int) *PunishmentsCreate { | ||||
| 	pc.mutation.SetID(i) | ||||
| 	return pc | ||||
| } | ||||
|  | ||||
| // Mutation returns the PunishmentsMutation object of the builder. | ||||
| func (pc *PunishmentsCreate) Mutation() *PunishmentsMutation { | ||||
| 	return pc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Punishments in the database. | ||||
| func (pc *PunishmentsCreate) Save(ctx context.Context) (*Punishments, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Punishments | ||||
| 	) | ||||
| 	if len(pc.hooks) == 0 { | ||||
| 		if err = pc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = pc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*PunishmentsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = pc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			pc.mutation = mutation | ||||
| 			if node, err = pc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(pc.hooks) - 1; i >= 0; i-- { | ||||
| 			if pc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = pc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, pc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Punishments) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from PunishmentsMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (pc *PunishmentsCreate) SaveX(ctx context.Context) *Punishments { | ||||
| 	v, err := pc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (pc *PunishmentsCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := pc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (pc *PunishmentsCreate) ExecX(ctx context.Context) { | ||||
| 	if err := pc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (pc *PunishmentsCreate) check() error { | ||||
| 	if _, ok := pc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Punishments.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := pc.mutation.Warnamount(); !ok { | ||||
| 		return &ValidationError{Name: "warnamount", err: errors.New(`ent: missing required field "Punishments.warnamount"`)} | ||||
| 	} | ||||
| 	if _, ok := pc.mutation.Actiontype(); !ok { | ||||
| 		return &ValidationError{Name: "actiontype", err: errors.New(`ent: missing required field "Punishments.actiontype"`)} | ||||
| 	} | ||||
| 	if _, ok := pc.mutation.Duration(); !ok { | ||||
| 		return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Punishments.duration"`)} | ||||
| 	} | ||||
| 	if _, ok := pc.mutation.Reason(); !ok { | ||||
| 		return &ValidationError{Name: "reason", err: errors.New(`ent: missing required field "Punishments.reason"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (pc *PunishmentsCreate) sqlSave(ctx context.Context) (*Punishments, error) { | ||||
| 	_node, _spec := pc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (pc *PunishmentsCreate) createSpec() (*Punishments, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Punishments{config: pc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: punishments.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: punishments.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := pc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := pc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := pc.mutation.Warnamount(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldWarnamount, | ||||
| 		}) | ||||
| 		_node.Warnamount = value | ||||
| 	} | ||||
| 	if value, ok := pc.mutation.Actiontype(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldActiontype, | ||||
| 		}) | ||||
| 		_node.Actiontype = value | ||||
| 	} | ||||
| 	if value, ok := pc.mutation.Duration(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldDuration, | ||||
| 		}) | ||||
| 		_node.Duration = value | ||||
| 	} | ||||
| 	if value, ok := pc.mutation.Reason(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldReason, | ||||
| 		}) | ||||
| 		_node.Reason = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // PunishmentsCreateBulk is the builder for creating many Punishments entities in bulk. | ||||
| type PunishmentsCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*PunishmentsCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Punishments entities in the database. | ||||
| func (pcb *PunishmentsCreateBulk) Save(ctx context.Context) ([]*Punishments, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) | ||||
| 	nodes := make([]*Punishments, len(pcb.builders)) | ||||
| 	mutators := make([]Mutator, len(pcb.builders)) | ||||
| 	for i := range pcb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := pcb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*PunishmentsMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, pcb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, pcb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (pcb *PunishmentsCreateBulk) SaveX(ctx context.Context) []*Punishments { | ||||
| 	v, err := pcb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (pcb *PunishmentsCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := pcb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (pcb *PunishmentsCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := pcb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/punishments_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/punishments_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| ) | ||||
|  | ||||
| // PunishmentsDelete is the builder for deleting a Punishments entity. | ||||
| type PunishmentsDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *PunishmentsMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the PunishmentsDelete builder. | ||||
| func (pd *PunishmentsDelete) Where(ps ...predicate.Punishments) *PunishmentsDelete { | ||||
| 	pd.mutation.Where(ps...) | ||||
| 	return pd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (pd *PunishmentsDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(pd.hooks) == 0 { | ||||
| 		affected, err = pd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*PunishmentsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			pd.mutation = mutation | ||||
| 			affected, err = pd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(pd.hooks) - 1; i >= 0; i-- { | ||||
| 			if pd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = pd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, pd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (pd *PunishmentsDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := pd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (pd *PunishmentsDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: punishments.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: punishments.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := pd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // PunishmentsDeleteOne is the builder for deleting a single Punishments entity. | ||||
| type PunishmentsDeleteOne struct { | ||||
| 	pd *PunishmentsDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (pdo *PunishmentsDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := pdo.pd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{punishments.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (pdo *PunishmentsDeleteOne) ExecX(ctx context.Context) { | ||||
| 	pdo.pd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/punishments_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/punishments_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| ) | ||||
|  | ||||
| // PunishmentsQuery is the builder for querying Punishments entities. | ||||
| type PunishmentsQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Punishments | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the PunishmentsQuery builder. | ||||
| func (pq *PunishmentsQuery) Where(ps ...predicate.Punishments) *PunishmentsQuery { | ||||
| 	pq.predicates = append(pq.predicates, ps...) | ||||
| 	return pq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (pq *PunishmentsQuery) Limit(limit int) *PunishmentsQuery { | ||||
| 	pq.limit = &limit | ||||
| 	return pq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (pq *PunishmentsQuery) Offset(offset int) *PunishmentsQuery { | ||||
| 	pq.offset = &offset | ||||
| 	return pq | ||||
| } | ||||
|  | ||||
| // 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 (pq *PunishmentsQuery) Unique(unique bool) *PunishmentsQuery { | ||||
| 	pq.unique = &unique | ||||
| 	return pq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (pq *PunishmentsQuery) Order(o ...OrderFunc) *PunishmentsQuery { | ||||
| 	pq.order = append(pq.order, o...) | ||||
| 	return pq | ||||
| } | ||||
|  | ||||
| // First returns the first Punishments entity from the query. | ||||
| // Returns a *NotFoundError when no Punishments was found. | ||||
| func (pq *PunishmentsQuery) First(ctx context.Context) (*Punishments, error) { | ||||
| 	nodes, err := pq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{punishments.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) FirstX(ctx context.Context) *Punishments { | ||||
| 	node, err := pq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Punishments ID from the query. | ||||
| // Returns a *NotFoundError when no Punishments ID was found. | ||||
| func (pq *PunishmentsQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = pq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{punishments.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := pq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Punishments entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Punishments entity is found. | ||||
| // Returns a *NotFoundError when no Punishments entities are found. | ||||
| func (pq *PunishmentsQuery) Only(ctx context.Context) (*Punishments, error) { | ||||
| 	nodes, err := pq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{punishments.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{punishments.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) OnlyX(ctx context.Context) *Punishments { | ||||
| 	node, err := pq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Punishments ID in the query. | ||||
| // Returns a *NotSingularError when more than one Punishments ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (pq *PunishmentsQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = pq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{punishments.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{punishments.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := pq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of PunishmentsSlice. | ||||
| func (pq *PunishmentsQuery) All(ctx context.Context) ([]*Punishments, error) { | ||||
| 	if err := pq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return pq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) AllX(ctx context.Context) []*Punishments { | ||||
| 	nodes, err := pq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Punishments IDs. | ||||
| func (pq *PunishmentsQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := pq.Select(punishments.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := pq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (pq *PunishmentsQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := pq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return pq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := pq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (pq *PunishmentsQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := pq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return pq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (pq *PunishmentsQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := pq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the PunishmentsQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (pq *PunishmentsQuery) Clone() *PunishmentsQuery { | ||||
| 	if pq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &PunishmentsQuery{ | ||||
| 		config:     pq.config, | ||||
| 		limit:      pq.limit, | ||||
| 		offset:     pq.offset, | ||||
| 		order:      append([]OrderFunc{}, pq.order...), | ||||
| 		predicates: append([]predicate.Punishments{}, pq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    pq.sql.Clone(), | ||||
| 		path:   pq.path, | ||||
| 		unique: pq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Punishments.Query(). | ||||
| //		GroupBy(punishments.FieldServerid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (pq *PunishmentsQuery) GroupBy(field string, fields ...string) *PunishmentsGroupBy { | ||||
| 	grbuild := &PunishmentsGroupBy{config: pq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := pq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return pq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = punishments.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Punishments.Query(). | ||||
| //		Select(punishments.FieldServerid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (pq *PunishmentsQuery) Select(fields ...string) *PunishmentsSelect { | ||||
| 	pq.fields = append(pq.fields, fields...) | ||||
| 	selbuild := &PunishmentsSelect{PunishmentsQuery: pq} | ||||
| 	selbuild.label = punishments.Label | ||||
| 	selbuild.flds, selbuild.scan = &pq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range pq.fields { | ||||
| 		if !punishments.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if pq.path != nil { | ||||
| 		prev, err := pq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		pq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Punishments, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Punishments{} | ||||
| 		_spec = pq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Punishments).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Punishments{config: pq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := pq.querySpec() | ||||
| 	_spec.Node.Columns = pq.fields | ||||
| 	if len(pq.fields) > 0 { | ||||
| 		_spec.Unique = pq.unique != nil && *pq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, pq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := pq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   punishments.Table, | ||||
| 			Columns: punishments.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: punishments.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   pq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := pq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := pq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, punishments.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != punishments.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := pq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := pq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := pq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := pq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (pq *PunishmentsQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(pq.driver.Dialect()) | ||||
| 	t1 := builder.Table(punishments.Table) | ||||
| 	columns := pq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = punishments.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if pq.sql != nil { | ||||
| 		selector = pq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if pq.unique != nil && *pq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range pq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range pq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := pq.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 := pq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // PunishmentsGroupBy is the group-by builder for Punishments entities. | ||||
| type PunishmentsGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (pgb *PunishmentsGroupBy) Aggregate(fns ...AggregateFunc) *PunishmentsGroupBy { | ||||
| 	pgb.fns = append(pgb.fns, fns...) | ||||
| 	return pgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (pgb *PunishmentsGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := pgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	pgb.sql = query | ||||
| 	return pgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (pgb *PunishmentsGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range pgb.fields { | ||||
| 		if !punishments.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := pgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := pgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (pgb *PunishmentsGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := pgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(pgb.fns)) | ||||
| 	for _, fn := range pgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(pgb.fields)+len(pgb.fns)) | ||||
| 		for _, f := range pgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(pgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // PunishmentsSelect is the builder for selecting fields of Punishments entities. | ||||
| type PunishmentsSelect struct { | ||||
| 	*PunishmentsQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ps *PunishmentsSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ps.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ps.sql = ps.PunishmentsQuery.sqlQuery(ctx) | ||||
| 	return ps.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ps *PunishmentsSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ps.sql.Query() | ||||
| 	if err := ps.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										375
									
								
								ent/punishments_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										375
									
								
								ent/punishments_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,375 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/punishments" | ||||
| ) | ||||
|  | ||||
| // PunishmentsUpdate is the builder for updating Punishments entities. | ||||
| type PunishmentsUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *PunishmentsMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the PunishmentsUpdate builder. | ||||
| func (pu *PunishmentsUpdate) Where(ps ...predicate.Punishments) *PunishmentsUpdate { | ||||
| 	pu.mutation.Where(ps...) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (pu *PunishmentsUpdate) SetServerid(s string) *PunishmentsUpdate { | ||||
| 	pu.mutation.SetServerid(s) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // SetWarnamount sets the "warnamount" field. | ||||
| func (pu *PunishmentsUpdate) SetWarnamount(s string) *PunishmentsUpdate { | ||||
| 	pu.mutation.SetWarnamount(s) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // SetActiontype sets the "actiontype" field. | ||||
| func (pu *PunishmentsUpdate) SetActiontype(s string) *PunishmentsUpdate { | ||||
| 	pu.mutation.SetActiontype(s) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (pu *PunishmentsUpdate) SetDuration(s string) *PunishmentsUpdate { | ||||
| 	pu.mutation.SetDuration(s) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (pu *PunishmentsUpdate) SetReason(s string) *PunishmentsUpdate { | ||||
| 	pu.mutation.SetReason(s) | ||||
| 	return pu | ||||
| } | ||||
|  | ||||
| // Mutation returns the PunishmentsMutation object of the builder. | ||||
| func (pu *PunishmentsUpdate) Mutation() *PunishmentsMutation { | ||||
| 	return pu.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (pu *PunishmentsUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(pu.hooks) == 0 { | ||||
| 		affected, err = pu.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*PunishmentsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			pu.mutation = mutation | ||||
| 			affected, err = pu.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(pu.hooks) - 1; i >= 0; i-- { | ||||
| 			if pu.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = pu.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, pu.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (pu *PunishmentsUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := pu.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (pu *PunishmentsUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := pu.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (pu *PunishmentsUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := pu.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (pu *PunishmentsUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   punishments.Table, | ||||
| 			Columns: punishments.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: punishments.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := pu.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := pu.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := pu.mutation.Warnamount(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldWarnamount, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := pu.mutation.Actiontype(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldActiontype, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := pu.mutation.Duration(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldDuration, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := pu.mutation.Reason(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldReason, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{punishments.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // PunishmentsUpdateOne is the builder for updating a single Punishments entity. | ||||
| type PunishmentsUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *PunishmentsMutation | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (puo *PunishmentsUpdateOne) SetServerid(s string) *PunishmentsUpdateOne { | ||||
| 	puo.mutation.SetServerid(s) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // SetWarnamount sets the "warnamount" field. | ||||
| func (puo *PunishmentsUpdateOne) SetWarnamount(s string) *PunishmentsUpdateOne { | ||||
| 	puo.mutation.SetWarnamount(s) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // SetActiontype sets the "actiontype" field. | ||||
| func (puo *PunishmentsUpdateOne) SetActiontype(s string) *PunishmentsUpdateOne { | ||||
| 	puo.mutation.SetActiontype(s) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // SetDuration sets the "duration" field. | ||||
| func (puo *PunishmentsUpdateOne) SetDuration(s string) *PunishmentsUpdateOne { | ||||
| 	puo.mutation.SetDuration(s) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // SetReason sets the "reason" field. | ||||
| func (puo *PunishmentsUpdateOne) SetReason(s string) *PunishmentsUpdateOne { | ||||
| 	puo.mutation.SetReason(s) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // Mutation returns the PunishmentsMutation object of the builder. | ||||
| func (puo *PunishmentsUpdateOne) Mutation() *PunishmentsMutation { | ||||
| 	return puo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (puo *PunishmentsUpdateOne) Select(field string, fields ...string) *PunishmentsUpdateOne { | ||||
| 	puo.fields = append([]string{field}, fields...) | ||||
| 	return puo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Punishments entity. | ||||
| func (puo *PunishmentsUpdateOne) Save(ctx context.Context) (*Punishments, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Punishments | ||||
| 	) | ||||
| 	if len(puo.hooks) == 0 { | ||||
| 		node, err = puo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*PunishmentsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			puo.mutation = mutation | ||||
| 			node, err = puo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(puo.hooks) - 1; i >= 0; i-- { | ||||
| 			if puo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = puo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, puo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Punishments) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from PunishmentsMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (puo *PunishmentsUpdateOne) SaveX(ctx context.Context) *Punishments { | ||||
| 	node, err := puo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (puo *PunishmentsUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := puo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (puo *PunishmentsUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := puo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (puo *PunishmentsUpdateOne) sqlSave(ctx context.Context) (_node *Punishments, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   punishments.Table, | ||||
| 			Columns: punishments.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: punishments.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := puo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Punishments.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := puo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, punishments.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !punishments.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != punishments.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := puo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := puo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := puo.mutation.Warnamount(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldWarnamount, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := puo.mutation.Actiontype(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldActiontype, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := puo.mutation.Duration(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldDuration, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := puo.mutation.Reason(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: punishments.FieldReason, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Punishments{config: puo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{punishments.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										94
									
								
								ent/runtime.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								ent/runtime.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,94 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/actions" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/schema" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/user" | ||||
| ) | ||||
|  | ||||
| // The init function reads all schema descriptors with runtime code | ||||
| // (default values, validators, hooks and policies) and stitches it | ||||
| // to their package variables. | ||||
| func init() { | ||||
| 	actionsFields := schema.Actions{}.Fields() | ||||
| 	_ = actionsFields | ||||
| 	// actionsDescTemp is the schema descriptor for temp field. | ||||
| 	actionsDescTemp := actionsFields[8].Descriptor() | ||||
| 	// actions.DefaultTemp holds the default value on creation for the temp field. | ||||
| 	actions.DefaultTemp = actionsDescTemp.Default.(bool) | ||||
| 	settingsFields := schema.Settings{}.Fields() | ||||
| 	_ = settingsFields | ||||
| 	// settingsDescLogger is the schema descriptor for logger field. | ||||
| 	settingsDescLogger := settingsFields[12].Descriptor() | ||||
| 	// settings.DefaultLogger holds the default value on creation for the logger field. | ||||
| 	settings.DefaultLogger = settingsDescLogger.Default.(bool) | ||||
| 	// settingsDescSpamprotection is the schema descriptor for spamprotection field. | ||||
| 	settingsDescSpamprotection := settingsFields[13].Descriptor() | ||||
| 	// settings.DefaultSpamprotection holds the default value on creation for the spamprotection field. | ||||
| 	settings.DefaultSpamprotection = settingsDescSpamprotection.Default.(bool) | ||||
| 	// settingsDescLinkprotection is the schema descriptor for linkprotection field. | ||||
| 	settingsDescLinkprotection := settingsFields[14].Descriptor() | ||||
| 	// settings.DefaultLinkprotection holds the default value on creation for the linkprotection field. | ||||
| 	settings.DefaultLinkprotection = settingsDescLinkprotection.Default.(bool) | ||||
| 	// settingsDescWordfilter is the schema descriptor for wordfilter field. | ||||
| 	settingsDescWordfilter := settingsFields[15].Descriptor() | ||||
| 	// settings.DefaultWordfilter holds the default value on creation for the wordfilter field. | ||||
| 	settings.DefaultWordfilter = settingsDescWordfilter.Default.(bool) | ||||
| 	// settingsDescGreetings is the schema descriptor for greetings field. | ||||
| 	settingsDescGreetings := settingsFields[16].Descriptor() | ||||
| 	// settings.DefaultGreetings holds the default value on creation for the greetings field. | ||||
| 	settings.DefaultGreetings = settingsDescGreetings.Default.(bool) | ||||
| 	// settingsDescApitoggle is the schema descriptor for apitoggle field. | ||||
| 	settingsDescApitoggle := settingsFields[17].Descriptor() | ||||
| 	// settings.DefaultApitoggle holds the default value on creation for the apitoggle field. | ||||
| 	settings.DefaultApitoggle = settingsDescApitoggle.Default.(bool) | ||||
| 	// settingsDescModeration is the schema descriptor for moderation field. | ||||
| 	settingsDescModeration := settingsFields[18].Descriptor() | ||||
| 	// settings.DefaultModeration holds the default value on creation for the moderation field. | ||||
| 	settings.DefaultModeration = settingsDescModeration.Default.(bool) | ||||
| 	// settingsDescAutomatedmoderation is the schema descriptor for automatedmoderation field. | ||||
| 	settingsDescAutomatedmoderation := settingsFields[19].Descriptor() | ||||
| 	// settings.DefaultAutomatedmoderation holds the default value on creation for the automatedmoderation field. | ||||
| 	settings.DefaultAutomatedmoderation = settingsDescAutomatedmoderation.Default.(bool) | ||||
| 	// settingsDescTwitchannounce is the schema descriptor for twitchannounce field. | ||||
| 	settingsDescTwitchannounce := settingsFields[20].Descriptor() | ||||
| 	// settings.DefaultTwitchannounce holds the default value on creation for the twitchannounce field. | ||||
| 	settings.DefaultTwitchannounce = settingsDescTwitchannounce.Default.(bool) | ||||
| 	// settingsDescTwitterannounce is the schema descriptor for twitterannounce field. | ||||
| 	settingsDescTwitterannounce := settingsFields[21].Descriptor() | ||||
| 	// settings.DefaultTwitterannounce holds the default value on creation for the twitterannounce field. | ||||
| 	settings.DefaultTwitterannounce = settingsDescTwitterannounce.Default.(bool) | ||||
| 	// settingsDescMusic is the schema descriptor for music field. | ||||
| 	settingsDescMusic := settingsFields[22].Descriptor() | ||||
| 	// settings.DefaultMusic holds the default value on creation for the music field. | ||||
| 	settings.DefaultMusic = settingsDescMusic.Default.(bool) | ||||
| 	// settingsDescStatspage is the schema descriptor for statspage field. | ||||
| 	settingsDescStatspage := settingsFields[23].Descriptor() | ||||
| 	// settings.DefaultStatspage holds the default value on creation for the statspage field. | ||||
| 	settings.DefaultStatspage = settingsDescStatspage.Default.(bool) | ||||
| 	// settingsDescStatsprivate is the schema descriptor for statsprivate field. | ||||
| 	settingsDescStatsprivate := settingsFields[24].Descriptor() | ||||
| 	// settings.DefaultStatsprivate holds the default value on creation for the statsprivate field. | ||||
| 	settings.DefaultStatsprivate = settingsDescStatsprivate.Default.(bool) | ||||
| 	// settingsDescStats is the schema descriptor for stats field. | ||||
| 	settingsDescStats := settingsFields[25].Descriptor() | ||||
| 	// settings.DefaultStats holds the default value on creation for the stats field. | ||||
| 	settings.DefaultStats = settingsDescStats.Default.(bool) | ||||
| 	userFields := schema.User{}.Fields() | ||||
| 	_ = userFields | ||||
| 	// userDescXp is the schema descriptor for xp field. | ||||
| 	userDescXp := userFields[4].Descriptor() | ||||
| 	// user.DefaultXp holds the default value on creation for the xp field. | ||||
| 	user.DefaultXp = userDescXp.Default.(int) | ||||
| 	// userDescLevel is the schema descriptor for level field. | ||||
| 	userDescLevel := userFields[5].Descriptor() | ||||
| 	// user.DefaultLevel holds the default value on creation for the level field. | ||||
| 	user.DefaultLevel = userDescLevel.Default.(int) | ||||
| 	// userDescMsgs is the schema descriptor for msgs field. | ||||
| 	userDescMsgs := userFields[6].Descriptor() | ||||
| 	// user.DefaultMsgs holds the default value on creation for the msgs field. | ||||
| 	user.DefaultMsgs = userDescMsgs.Default.(int) | ||||
| } | ||||
							
								
								
									
										10
									
								
								ent/runtime/runtime.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								ent/runtime/runtime.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package runtime | ||||
|  | ||||
| // The schema-stitching logic is generated in github.com/FrankenBotDev/FrankenAPI/ent/runtime.go | ||||
|  | ||||
| const ( | ||||
| 	Version = "v0.11.1"                                         // Version of ent codegen. | ||||
| 	Sum     = "h1:im67R+2W3Nee2bNS2YnoYz8oAF0Qz4AOlIvKRIAEISY=" // Sum of ent codegen. | ||||
| ) | ||||
							
								
								
									
										31
									
								
								ent/schema/actions.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								ent/schema/actions.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Actions holds the schema definition for the Actions entity. | ||||
| type Actions struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Actions. | ||||
| func (Actions) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("refid"), | ||||
| 		field.String("commiter"), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("target"), | ||||
| 		field.String("type"), | ||||
| 		field.String("duration"), | ||||
| 		field.String("reason"), | ||||
| 		field.Bool("temp").Default(false), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Actions. | ||||
| func (Actions) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										26
									
								
								ent/schema/authorizables.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								ent/schema/authorizables.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Authorizables holds the schema definition for the Authorizables entity. | ||||
| type Authorizables struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Authorizables. | ||||
| func (Authorizables) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.String("username"), | ||||
| 		field.String("password"), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("userid"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Authorizables. | ||||
| func (Authorizables) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										25
									
								
								ent/schema/blacklist.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								ent/schema/blacklist.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Blacklist holds the schema definition for the Blacklist entity. | ||||
| type Blacklist struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Blacklist. | ||||
| func (Blacklist) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("word"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Blacklist. | ||||
| func (Blacklist) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										27
									
								
								ent/schema/logging.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								ent/schema/logging.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Logging holds the schema definition for the Logging entity. | ||||
| type Logging struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Logging. | ||||
| func (Logging) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("type"), | ||||
| 		field.String("commiter"), | ||||
| 		field.String("description"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Logging. | ||||
| func (Logging) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										28
									
								
								ent/schema/punishments.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								ent/schema/punishments.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,28 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Punishments holds the schema definition for the Punishments entity. | ||||
| type Punishments struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Punishments. | ||||
| func (Punishments) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("warnamount"), | ||||
| 		field.String("actiontype"), | ||||
| 		field.String("duration"), | ||||
| 		field.String("reason"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Punishments. | ||||
| func (Punishments) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										27
									
								
								ent/schema/servers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								ent/schema/servers.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Servers holds the schema definition for the Servers entity. | ||||
| type Servers struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Servers. | ||||
| func (Servers) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("userid"), | ||||
| 		field.String("serverid"), | ||||
| 		field.Bool("isOwner"), | ||||
| 		field.String("permission"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Servers. | ||||
| func (Servers) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										48
									
								
								ent/schema/settings.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								ent/schema/settings.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Settings holds the schema definition for the Settings entity. | ||||
| type Settings struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Settings. | ||||
| func (Settings) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("servername"), | ||||
| 		field.String("ownerid"), | ||||
| 		field.String("permtoken"), | ||||
| 		field.String("apitoken"), | ||||
| 		field.String("statspagemode"), | ||||
| 		field.String("loggerchannel"), | ||||
| 		field.String("spamchannel"), | ||||
| 		field.String("greeterchannel"), | ||||
| 		field.String("greetermode"), | ||||
| 		field.String("announcechannel"), | ||||
| 		field.Bool("logger").Default(false), | ||||
| 		field.Bool("spamprotection").Default(false), | ||||
| 		field.Bool("linkprotection").Default(false), | ||||
| 		field.Bool("wordfilter").Default(false), | ||||
| 		field.Bool("greetings").Default(false), | ||||
| 		field.Bool("apitoggle").Default(false), | ||||
| 		field.Bool("moderation").Default(false), | ||||
| 		field.Bool("automatedmoderation").Default(false), | ||||
| 		field.Bool("twitchannounce").Default(false), | ||||
| 		field.Bool("twitterannounce").Default(false), | ||||
| 		field.Bool("music").Default(false), | ||||
| 		field.Bool("statspage").Default(false), | ||||
| 		field.Bool("statsprivate").Default(false), | ||||
| 		field.Bool("stats").Default(false), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Settings. | ||||
| func (Settings) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										26
									
								
								ent/schema/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								ent/schema/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Socialmedia holds the schema definition for the Socialmedia entity. | ||||
| type Socialmedia struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Socialmedia. | ||||
| func (Socialmedia) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("type"), | ||||
| 		field.String("identificator"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Socialmedia. | ||||
| func (Socialmedia) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										29
									
								
								ent/schema/support.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								ent/schema/support.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,29 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Support holds the schema definition for the Support entity. | ||||
| type Support struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Support. | ||||
| func (Support) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("refid"), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("creator"), | ||||
| 		field.String("status"), | ||||
| 		field.String("title"), | ||||
| 		field.String("description"), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Support. | ||||
| func (Support) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										33
									
								
								ent/schema/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								ent/schema/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/dialect/entsql" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // SupportResponse holds the schema definition for the SupportResponse entity. | ||||
| type SupportResponse struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the SupportResponse. | ||||
| func (SupportResponse) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("refid"), | ||||
| 		field.String("writer"), | ||||
| 		field.String("message"), | ||||
| 		field.String("type"), | ||||
| 		field.String("rtcchannel"), | ||||
| 		field.Bool("isread"), | ||||
| 		field.Time("created").Annotations(&entsql.Annotation{ | ||||
| 			Default: "CURRENT_TIMESTAMP", | ||||
| 		}), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the SupportResponse. | ||||
| func (SupportResponse) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										33
									
								
								ent/schema/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								ent/schema/user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/dialect/entsql" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // User holds the schema definition for the User entity. | ||||
| type User struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the User. | ||||
| func (User) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("userid"), | ||||
| 		field.String("username"), | ||||
| 		field.Int("xp").Default(0), | ||||
| 		field.Int("level").Default(1), | ||||
| 		field.Int("msgs").Default(0), | ||||
| 		field.Time("created").Annotations(&entsql.Annotation{ | ||||
| 			Default: "CURRENT_TIMESTAMP", | ||||
| 		}), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the User. | ||||
| func (User) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										30
									
								
								ent/schema/warns.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								ent/schema/warns.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,30 @@ | ||||
| package schema | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| ) | ||||
|  | ||||
| // Warns holds the schema definition for the Warns entity. | ||||
| type Warns struct { | ||||
| 	ent.Schema | ||||
| } | ||||
|  | ||||
| // Fields of the Warns. | ||||
| func (Warns) Fields() []ent.Field { | ||||
| 	return []ent.Field{ | ||||
| 		field.Int("id").Unique(), | ||||
| 		field.String("emitter"), | ||||
| 		field.String("serverid"), | ||||
| 		field.String("target"), | ||||
| 		field.String("type"), | ||||
| 		field.String("duration"), | ||||
| 		field.String("reason"), | ||||
| 		field.String("refid").Unique(), | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Edges of the Warns. | ||||
| func (Warns) Edges() []ent.Edge { | ||||
| 	return nil | ||||
| } | ||||
							
								
								
									
										134
									
								
								ent/servers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								ent/servers.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,134 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| ) | ||||
|  | ||||
| // Servers is the model entity for the Servers schema. | ||||
| type Servers struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Userid holds the value of the "userid" field. | ||||
| 	Userid string `json:"userid,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// IsOwner holds the value of the "isOwner" field. | ||||
| 	IsOwner bool `json:"isOwner,omitempty"` | ||||
| 	// Permission holds the value of the "permission" field. | ||||
| 	Permission string `json:"permission,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Servers) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case servers.FieldIsOwner: | ||||
| 			values[i] = new(sql.NullBool) | ||||
| 		case servers.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case servers.FieldUserid, servers.FieldServerid, servers.FieldPermission: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Servers", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Servers fields. | ||||
| func (s *Servers) assignValues(columns []string, values []interface{}) 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 servers.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			s.ID = int(value.Int64) | ||||
| 		case servers.FieldUserid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field userid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Userid = value.String | ||||
| 			} | ||||
| 		case servers.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Serverid = value.String | ||||
| 			} | ||||
| 		case servers.FieldIsOwner: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field isOwner", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.IsOwner = value.Bool | ||||
| 			} | ||||
| 		case servers.FieldPermission: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field permission", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Permission = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Servers. | ||||
| // Note that you need to call Servers.Unwrap() before calling this method if this Servers | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (s *Servers) Update() *ServersUpdateOne { | ||||
| 	return (&ServersClient{config: s.config}).UpdateOne(s) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Servers 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 (s *Servers) Unwrap() *Servers { | ||||
| 	_tx, ok := s.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Servers is not a transactional entity") | ||||
| 	} | ||||
| 	s.config.driver = _tx.drv | ||||
| 	return s | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (s *Servers) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Servers(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) | ||||
| 	builder.WriteString("userid=") | ||||
| 	builder.WriteString(s.Userid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(s.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("isOwner=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.IsOwner)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("permission=") | ||||
| 	builder.WriteString(s.Permission) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // ServersSlice is a parsable slice of Servers. | ||||
| type ServersSlice []*Servers | ||||
|  | ||||
| func (s ServersSlice) config(cfg config) { | ||||
| 	for _i := range s { | ||||
| 		s[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										39
									
								
								ent/servers/servers.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								ent/servers/servers.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,39 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package servers | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the servers type in the database. | ||||
| 	Label = "servers" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldUserid holds the string denoting the userid field in the database. | ||||
| 	FieldUserid = "userid" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldIsOwner holds the string denoting the isowner field in the database. | ||||
| 	FieldIsOwner = "is_owner" | ||||
| 	// FieldPermission holds the string denoting the permission field in the database. | ||||
| 	FieldPermission = "permission" | ||||
| 	// Table holds the table name of the servers in the database. | ||||
| 	Table = "servers" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for servers fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldUserid, | ||||
| 	FieldServerid, | ||||
| 	FieldIsOwner, | ||||
| 	FieldPermission, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										486
									
								
								ent/servers/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										486
									
								
								ent/servers/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,486 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package servers | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Userid applies equality check predicate on the "userid" field. It's identical to UseridEQ. | ||||
| func Userid(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IsOwner applies equality check predicate on the "isOwner" field. It's identical to IsOwnerEQ. | ||||
| func IsOwner(v bool) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIsOwner), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Permission applies equality check predicate on the "permission" field. It's identical to PermissionEQ. | ||||
| func Permission(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridEQ applies the EQ predicate on the "userid" field. | ||||
| func UseridEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridNEQ applies the NEQ predicate on the "userid" field. | ||||
| func UseridNEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridIn applies the In predicate on the "userid" field. | ||||
| func UseridIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldUserid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridNotIn applies the NotIn predicate on the "userid" field. | ||||
| func UseridNotIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldUserid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridGT applies the GT predicate on the "userid" field. | ||||
| func UseridGT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridGTE applies the GTE predicate on the "userid" field. | ||||
| func UseridGTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridLT applies the LT predicate on the "userid" field. | ||||
| func UseridLT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridLTE applies the LTE predicate on the "userid" field. | ||||
| func UseridLTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridContains applies the Contains predicate on the "userid" field. | ||||
| func UseridContains(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridHasPrefix applies the HasPrefix predicate on the "userid" field. | ||||
| func UseridHasPrefix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridHasSuffix applies the HasSuffix predicate on the "userid" field. | ||||
| func UseridHasSuffix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridEqualFold applies the EqualFold predicate on the "userid" field. | ||||
| func UseridEqualFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // UseridContainsFold applies the ContainsFold predicate on the "userid" field. | ||||
| func UseridContainsFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldUserid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IsOwnerEQ applies the EQ predicate on the "isOwner" field. | ||||
| func IsOwnerEQ(v bool) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIsOwner), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IsOwnerNEQ applies the NEQ predicate on the "isOwner" field. | ||||
| func IsOwnerNEQ(v bool) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldIsOwner), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionEQ applies the EQ predicate on the "permission" field. | ||||
| func PermissionEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionNEQ applies the NEQ predicate on the "permission" field. | ||||
| func PermissionNEQ(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionIn applies the In predicate on the "permission" field. | ||||
| func PermissionIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldPermission), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionNotIn applies the NotIn predicate on the "permission" field. | ||||
| func PermissionNotIn(vs ...string) predicate.Servers { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldPermission), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionGT applies the GT predicate on the "permission" field. | ||||
| func PermissionGT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionGTE applies the GTE predicate on the "permission" field. | ||||
| func PermissionGTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionLT applies the LT predicate on the "permission" field. | ||||
| func PermissionLT(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionLTE applies the LTE predicate on the "permission" field. | ||||
| func PermissionLTE(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionContains applies the Contains predicate on the "permission" field. | ||||
| func PermissionContains(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionHasPrefix applies the HasPrefix predicate on the "permission" field. | ||||
| func PermissionHasPrefix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionHasSuffix applies the HasSuffix predicate on the "permission" field. | ||||
| func PermissionHasSuffix(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionEqualFold applies the EqualFold predicate on the "permission" field. | ||||
| func PermissionEqualFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // PermissionContainsFold applies the ContainsFold predicate on the "permission" field. | ||||
| func PermissionContainsFold(v string) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldPermission), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Servers) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Servers) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Servers) predicate.Servers { | ||||
| 	return predicate.Servers(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										289
									
								
								ent/servers_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										289
									
								
								ent/servers_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,289 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| ) | ||||
|  | ||||
| // ServersCreate is the builder for creating a Servers entity. | ||||
| type ServersCreate struct { | ||||
| 	config | ||||
| 	mutation *ServersMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (sc *ServersCreate) SetUserid(s string) *ServersCreate { | ||||
| 	sc.mutation.SetUserid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (sc *ServersCreate) SetServerid(s string) *ServersCreate { | ||||
| 	sc.mutation.SetServerid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetIsOwner sets the "isOwner" field. | ||||
| func (sc *ServersCreate) SetIsOwner(b bool) *ServersCreate { | ||||
| 	sc.mutation.SetIsOwner(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetPermission sets the "permission" field. | ||||
| func (sc *ServersCreate) SetPermission(s string) *ServersCreate { | ||||
| 	sc.mutation.SetPermission(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (sc *ServersCreate) SetID(i int) *ServersCreate { | ||||
| 	sc.mutation.SetID(i) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // Mutation returns the ServersMutation object of the builder. | ||||
| func (sc *ServersCreate) Mutation() *ServersMutation { | ||||
| 	return sc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Servers in the database. | ||||
| func (sc *ServersCreate) Save(ctx context.Context) (*Servers, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Servers | ||||
| 	) | ||||
| 	if len(sc.hooks) == 0 { | ||||
| 		if err = sc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = sc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ServersMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = sc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			sc.mutation = mutation | ||||
| 			if node, err = sc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(sc.hooks) - 1; i >= 0; i-- { | ||||
| 			if sc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, sc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Servers) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from ServersMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (sc *ServersCreate) SaveX(ctx context.Context) *Servers { | ||||
| 	v, err := sc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (sc *ServersCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := sc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sc *ServersCreate) ExecX(ctx context.Context) { | ||||
| 	if err := sc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (sc *ServersCreate) check() error { | ||||
| 	if _, ok := sc.mutation.Userid(); !ok { | ||||
| 		return &ValidationError{Name: "userid", err: errors.New(`ent: missing required field "Servers.userid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Servers.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.IsOwner(); !ok { | ||||
| 		return &ValidationError{Name: "isOwner", err: errors.New(`ent: missing required field "Servers.isOwner"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Permission(); !ok { | ||||
| 		return &ValidationError{Name: "permission", err: errors.New(`ent: missing required field "Servers.permission"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sc *ServersCreate) sqlSave(ctx context.Context) (*Servers, error) { | ||||
| 	_node, _spec := sc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (sc *ServersCreate) createSpec() (*Servers, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Servers{config: sc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: servers.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: servers.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := sc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Userid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldUserid, | ||||
| 		}) | ||||
| 		_node.Userid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.IsOwner(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldIsOwner, | ||||
| 		}) | ||||
| 		_node.IsOwner = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Permission(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldPermission, | ||||
| 		}) | ||||
| 		_node.Permission = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // ServersCreateBulk is the builder for creating many Servers entities in bulk. | ||||
| type ServersCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*ServersCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Servers entities in the database. | ||||
| func (scb *ServersCreateBulk) Save(ctx context.Context) ([]*Servers, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) | ||||
| 	nodes := make([]*Servers, len(scb.builders)) | ||||
| 	mutators := make([]Mutator, len(scb.builders)) | ||||
| 	for i := range scb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := scb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*ServersMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, scb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, scb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (scb *ServersCreateBulk) SaveX(ctx context.Context) []*Servers { | ||||
| 	v, err := scb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (scb *ServersCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := scb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (scb *ServersCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := scb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/servers_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/servers_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| ) | ||||
|  | ||||
| // ServersDelete is the builder for deleting a Servers entity. | ||||
| type ServersDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *ServersMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the ServersDelete builder. | ||||
| func (sd *ServersDelete) Where(ps ...predicate.Servers) *ServersDelete { | ||||
| 	sd.mutation.Where(ps...) | ||||
| 	return sd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (sd *ServersDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(sd.hooks) == 0 { | ||||
| 		affected, err = sd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ServersMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sd.mutation = mutation | ||||
| 			affected, err = sd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(sd.hooks) - 1; i >= 0; i-- { | ||||
| 			if sd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, sd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sd *ServersDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := sd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (sd *ServersDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: servers.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: servers.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := sd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ServersDeleteOne is the builder for deleting a single Servers entity. | ||||
| type ServersDeleteOne struct { | ||||
| 	sd *ServersDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (sdo *ServersDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := sdo.sd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{servers.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sdo *ServersDeleteOne) ExecX(ctx context.Context) { | ||||
| 	sdo.sd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/servers_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/servers_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| ) | ||||
|  | ||||
| // ServersQuery is the builder for querying Servers entities. | ||||
| type ServersQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Servers | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the ServersQuery builder. | ||||
| func (sq *ServersQuery) Where(ps ...predicate.Servers) *ServersQuery { | ||||
| 	sq.predicates = append(sq.predicates, ps...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (sq *ServersQuery) Limit(limit int) *ServersQuery { | ||||
| 	sq.limit = &limit | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (sq *ServersQuery) Offset(offset int) *ServersQuery { | ||||
| 	sq.offset = &offset | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // 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 (sq *ServersQuery) Unique(unique bool) *ServersQuery { | ||||
| 	sq.unique = &unique | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (sq *ServersQuery) Order(o ...OrderFunc) *ServersQuery { | ||||
| 	sq.order = append(sq.order, o...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // First returns the first Servers entity from the query. | ||||
| // Returns a *NotFoundError when no Servers was found. | ||||
| func (sq *ServersQuery) First(ctx context.Context) (*Servers, error) { | ||||
| 	nodes, err := sq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{servers.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (sq *ServersQuery) FirstX(ctx context.Context) *Servers { | ||||
| 	node, err := sq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Servers ID from the query. | ||||
| // Returns a *NotFoundError when no Servers ID was found. | ||||
| func (sq *ServersQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{servers.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (sq *ServersQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := sq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Servers entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Servers entity is found. | ||||
| // Returns a *NotFoundError when no Servers entities are found. | ||||
| func (sq *ServersQuery) Only(ctx context.Context) (*Servers, error) { | ||||
| 	nodes, err := sq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{servers.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{servers.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (sq *ServersQuery) OnlyX(ctx context.Context) *Servers { | ||||
| 	node, err := sq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Servers ID in the query. | ||||
| // Returns a *NotSingularError when more than one Servers ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (sq *ServersQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{servers.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{servers.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (sq *ServersQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := sq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of ServersSlice. | ||||
| func (sq *ServersQuery) All(ctx context.Context) ([]*Servers, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return sq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (sq *ServersQuery) AllX(ctx context.Context) []*Servers { | ||||
| 	nodes, err := sq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Servers IDs. | ||||
| func (sq *ServersQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := sq.Select(servers.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (sq *ServersQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := sq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (sq *ServersQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return sq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (sq *ServersQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := sq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (sq *ServersQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return sq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (sq *ServersQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := sq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the ServersQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (sq *ServersQuery) Clone() *ServersQuery { | ||||
| 	if sq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &ServersQuery{ | ||||
| 		config:     sq.config, | ||||
| 		limit:      sq.limit, | ||||
| 		offset:     sq.offset, | ||||
| 		order:      append([]OrderFunc{}, sq.order...), | ||||
| 		predicates: append([]predicate.Servers{}, sq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    sq.sql.Clone(), | ||||
| 		path:   sq.path, | ||||
| 		unique: sq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Userid string `json:"userid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Servers.Query(). | ||||
| //		GroupBy(servers.FieldUserid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *ServersQuery) GroupBy(field string, fields ...string) *ServersGroupBy { | ||||
| 	grbuild := &ServersGroupBy{config: sq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := sq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return sq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = servers.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Userid string `json:"userid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Servers.Query(). | ||||
| //		Select(servers.FieldUserid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *ServersQuery) Select(fields ...string) *ServersSelect { | ||||
| 	sq.fields = append(sq.fields, fields...) | ||||
| 	selbuild := &ServersSelect{ServersQuery: sq} | ||||
| 	selbuild.label = servers.Label | ||||
| 	selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range sq.fields { | ||||
| 		if !servers.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if sq.path != nil { | ||||
| 		prev, err := sq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		sq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Servers, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Servers{} | ||||
| 		_spec = sq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Servers).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Servers{config: sq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := sq.querySpec() | ||||
| 	_spec.Node.Columns = sq.fields | ||||
| 	if len(sq.fields) > 0 { | ||||
| 		_spec.Unique = sq.unique != nil && *sq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, sq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := sq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   servers.Table, | ||||
| 			Columns: servers.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: servers.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   sq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := sq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := sq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, servers.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != servers.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := sq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := sq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := sq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := sq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (sq *ServersQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(sq.driver.Dialect()) | ||||
| 	t1 := builder.Table(servers.Table) | ||||
| 	columns := sq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = servers.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if sq.sql != nil { | ||||
| 		selector = sq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if sq.unique != nil && *sq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range sq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range sq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := sq.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 := sq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // ServersGroupBy is the group-by builder for Servers entities. | ||||
| type ServersGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (sgb *ServersGroupBy) Aggregate(fns ...AggregateFunc) *ServersGroupBy { | ||||
| 	sgb.fns = append(sgb.fns, fns...) | ||||
| 	return sgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (sgb *ServersGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := sgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	sgb.sql = query | ||||
| 	return sgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (sgb *ServersGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range sgb.fields { | ||||
| 		if !servers.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := sgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := sgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (sgb *ServersGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := sgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(sgb.fns)) | ||||
| 	for _, fn := range sgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(sgb.fields)+len(sgb.fns)) | ||||
| 		for _, f := range sgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(sgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // ServersSelect is the builder for selecting fields of Servers entities. | ||||
| type ServersSelect struct { | ||||
| 	*ServersQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ss *ServersSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ss.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ss.sql = ss.ServersQuery.sqlQuery(ctx) | ||||
| 	return ss.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ss *ServersSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ss.sql.Query() | ||||
| 	if err := ss.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										349
									
								
								ent/servers_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										349
									
								
								ent/servers_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,349 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/servers" | ||||
| ) | ||||
|  | ||||
| // ServersUpdate is the builder for updating Servers entities. | ||||
| type ServersUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *ServersMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the ServersUpdate builder. | ||||
| func (su *ServersUpdate) Where(ps ...predicate.Servers) *ServersUpdate { | ||||
| 	su.mutation.Where(ps...) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (su *ServersUpdate) SetUserid(s string) *ServersUpdate { | ||||
| 	su.mutation.SetUserid(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (su *ServersUpdate) SetServerid(s string) *ServersUpdate { | ||||
| 	su.mutation.SetServerid(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetIsOwner sets the "isOwner" field. | ||||
| func (su *ServersUpdate) SetIsOwner(b bool) *ServersUpdate { | ||||
| 	su.mutation.SetIsOwner(b) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetPermission sets the "permission" field. | ||||
| func (su *ServersUpdate) SetPermission(s string) *ServersUpdate { | ||||
| 	su.mutation.SetPermission(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // Mutation returns the ServersMutation object of the builder. | ||||
| func (su *ServersUpdate) Mutation() *ServersMutation { | ||||
| 	return su.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (su *ServersUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(su.hooks) == 0 { | ||||
| 		affected, err = su.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ServersMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			su.mutation = mutation | ||||
| 			affected, err = su.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(su.hooks) - 1; i >= 0; i-- { | ||||
| 			if su.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = su.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, su.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (su *ServersUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := su.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (su *ServersUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := su.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (su *ServersUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := su.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (su *ServersUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   servers.Table, | ||||
| 			Columns: servers.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: servers.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := su.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Userid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldUserid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.IsOwner(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldIsOwner, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Permission(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldPermission, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{servers.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // ServersUpdateOne is the builder for updating a single Servers entity. | ||||
| type ServersUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *ServersMutation | ||||
| } | ||||
|  | ||||
| // SetUserid sets the "userid" field. | ||||
| func (suo *ServersUpdateOne) SetUserid(s string) *ServersUpdateOne { | ||||
| 	suo.mutation.SetUserid(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (suo *ServersUpdateOne) SetServerid(s string) *ServersUpdateOne { | ||||
| 	suo.mutation.SetServerid(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetIsOwner sets the "isOwner" field. | ||||
| func (suo *ServersUpdateOne) SetIsOwner(b bool) *ServersUpdateOne { | ||||
| 	suo.mutation.SetIsOwner(b) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetPermission sets the "permission" field. | ||||
| func (suo *ServersUpdateOne) SetPermission(s string) *ServersUpdateOne { | ||||
| 	suo.mutation.SetPermission(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Mutation returns the ServersMutation object of the builder. | ||||
| func (suo *ServersUpdateOne) Mutation() *ServersMutation { | ||||
| 	return suo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (suo *ServersUpdateOne) Select(field string, fields ...string) *ServersUpdateOne { | ||||
| 	suo.fields = append([]string{field}, fields...) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Servers entity. | ||||
| func (suo *ServersUpdateOne) Save(ctx context.Context) (*Servers, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Servers | ||||
| 	) | ||||
| 	if len(suo.hooks) == 0 { | ||||
| 		node, err = suo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*ServersMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			suo.mutation = mutation | ||||
| 			node, err = suo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(suo.hooks) - 1; i >= 0; i-- { | ||||
| 			if suo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = suo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, suo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Servers) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from ServersMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (suo *ServersUpdateOne) SaveX(ctx context.Context) *Servers { | ||||
| 	node, err := suo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (suo *ServersUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := suo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (suo *ServersUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := suo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (suo *ServersUpdateOne) sqlSave(ctx context.Context) (_node *Servers, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   servers.Table, | ||||
| 			Columns: servers.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: servers.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := suo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Servers.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := suo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, servers.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !servers.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != servers.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := suo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Userid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldUserid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.IsOwner(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldIsOwner, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Permission(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: servers.FieldPermission, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Servers{config: suo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{servers.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										365
									
								
								ent/settings.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										365
									
								
								ent/settings.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,365 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| ) | ||||
|  | ||||
| // Settings is the model entity for the Settings schema. | ||||
| type Settings struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Servername holds the value of the "servername" field. | ||||
| 	Servername string `json:"servername,omitempty"` | ||||
| 	// Ownerid holds the value of the "ownerid" field. | ||||
| 	Ownerid string `json:"ownerid,omitempty"` | ||||
| 	// Permtoken holds the value of the "permtoken" field. | ||||
| 	Permtoken string `json:"permtoken,omitempty"` | ||||
| 	// Apitoken holds the value of the "apitoken" field. | ||||
| 	Apitoken string `json:"apitoken,omitempty"` | ||||
| 	// Statspagemode holds the value of the "statspagemode" field. | ||||
| 	Statspagemode string `json:"statspagemode,omitempty"` | ||||
| 	// Loggerchannel holds the value of the "loggerchannel" field. | ||||
| 	Loggerchannel string `json:"loggerchannel,omitempty"` | ||||
| 	// Spamchannel holds the value of the "spamchannel" field. | ||||
| 	Spamchannel string `json:"spamchannel,omitempty"` | ||||
| 	// Greeterchannel holds the value of the "greeterchannel" field. | ||||
| 	Greeterchannel string `json:"greeterchannel,omitempty"` | ||||
| 	// Greetermode holds the value of the "greetermode" field. | ||||
| 	Greetermode string `json:"greetermode,omitempty"` | ||||
| 	// Announcechannel holds the value of the "announcechannel" field. | ||||
| 	Announcechannel string `json:"announcechannel,omitempty"` | ||||
| 	// Logger holds the value of the "logger" field. | ||||
| 	Logger bool `json:"logger,omitempty"` | ||||
| 	// Spamprotection holds the value of the "spamprotection" field. | ||||
| 	Spamprotection bool `json:"spamprotection,omitempty"` | ||||
| 	// Linkprotection holds the value of the "linkprotection" field. | ||||
| 	Linkprotection bool `json:"linkprotection,omitempty"` | ||||
| 	// Wordfilter holds the value of the "wordfilter" field. | ||||
| 	Wordfilter bool `json:"wordfilter,omitempty"` | ||||
| 	// Greetings holds the value of the "greetings" field. | ||||
| 	Greetings bool `json:"greetings,omitempty"` | ||||
| 	// Apitoggle holds the value of the "apitoggle" field. | ||||
| 	Apitoggle bool `json:"apitoggle,omitempty"` | ||||
| 	// Moderation holds the value of the "moderation" field. | ||||
| 	Moderation bool `json:"moderation,omitempty"` | ||||
| 	// Automatedmoderation holds the value of the "automatedmoderation" field. | ||||
| 	Automatedmoderation bool `json:"automatedmoderation,omitempty"` | ||||
| 	// Twitchannounce holds the value of the "twitchannounce" field. | ||||
| 	Twitchannounce bool `json:"twitchannounce,omitempty"` | ||||
| 	// Twitterannounce holds the value of the "twitterannounce" field. | ||||
| 	Twitterannounce bool `json:"twitterannounce,omitempty"` | ||||
| 	// Music holds the value of the "music" field. | ||||
| 	Music bool `json:"music,omitempty"` | ||||
| 	// Statspage holds the value of the "statspage" field. | ||||
| 	Statspage bool `json:"statspage,omitempty"` | ||||
| 	// Statsprivate holds the value of the "statsprivate" field. | ||||
| 	Statsprivate bool `json:"statsprivate,omitempty"` | ||||
| 	// Stats holds the value of the "stats" field. | ||||
| 	Stats bool `json:"stats,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Settings) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case settings.FieldLogger, settings.FieldSpamprotection, settings.FieldLinkprotection, settings.FieldWordfilter, settings.FieldGreetings, settings.FieldApitoggle, settings.FieldModeration, settings.FieldAutomatedmoderation, settings.FieldTwitchannounce, settings.FieldTwitterannounce, settings.FieldMusic, settings.FieldStatspage, settings.FieldStatsprivate, settings.FieldStats: | ||||
| 			values[i] = new(sql.NullBool) | ||||
| 		case settings.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case settings.FieldServerid, settings.FieldServername, settings.FieldOwnerid, settings.FieldPermtoken, settings.FieldApitoken, settings.FieldStatspagemode, settings.FieldLoggerchannel, settings.FieldSpamchannel, settings.FieldGreeterchannel, settings.FieldGreetermode, settings.FieldAnnouncechannel: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Settings", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Settings fields. | ||||
| func (s *Settings) assignValues(columns []string, values []interface{}) 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 settings.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			s.ID = int(value.Int64) | ||||
| 		case settings.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Serverid = value.String | ||||
| 			} | ||||
| 		case settings.FieldServername: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field servername", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Servername = value.String | ||||
| 			} | ||||
| 		case settings.FieldOwnerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field ownerid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Ownerid = value.String | ||||
| 			} | ||||
| 		case settings.FieldPermtoken: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field permtoken", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Permtoken = value.String | ||||
| 			} | ||||
| 		case settings.FieldApitoken: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field apitoken", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Apitoken = value.String | ||||
| 			} | ||||
| 		case settings.FieldStatspagemode: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field statspagemode", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Statspagemode = value.String | ||||
| 			} | ||||
| 		case settings.FieldLoggerchannel: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field loggerchannel", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Loggerchannel = value.String | ||||
| 			} | ||||
| 		case settings.FieldSpamchannel: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field spamchannel", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Spamchannel = value.String | ||||
| 			} | ||||
| 		case settings.FieldGreeterchannel: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field greeterchannel", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Greeterchannel = value.String | ||||
| 			} | ||||
| 		case settings.FieldGreetermode: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field greetermode", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Greetermode = value.String | ||||
| 			} | ||||
| 		case settings.FieldAnnouncechannel: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field announcechannel", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Announcechannel = value.String | ||||
| 			} | ||||
| 		case settings.FieldLogger: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field logger", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Logger = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldSpamprotection: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field spamprotection", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Spamprotection = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldLinkprotection: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field linkprotection", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Linkprotection = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldWordfilter: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field wordfilter", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Wordfilter = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldGreetings: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field greetings", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Greetings = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldApitoggle: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field apitoggle", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Apitoggle = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldModeration: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field moderation", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Moderation = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldAutomatedmoderation: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field automatedmoderation", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Automatedmoderation = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldTwitchannounce: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field twitchannounce", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Twitchannounce = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldTwitterannounce: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field twitterannounce", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Twitterannounce = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldMusic: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field music", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Music = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldStatspage: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field statspage", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Statspage = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldStatsprivate: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field statsprivate", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Statsprivate = value.Bool | ||||
| 			} | ||||
| 		case settings.FieldStats: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field stats", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Stats = value.Bool | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Settings. | ||||
| // Note that you need to call Settings.Unwrap() before calling this method if this Settings | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (s *Settings) Update() *SettingsUpdateOne { | ||||
| 	return (&SettingsClient{config: s.config}).UpdateOne(s) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Settings 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 (s *Settings) Unwrap() *Settings { | ||||
| 	_tx, ok := s.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Settings is not a transactional entity") | ||||
| 	} | ||||
| 	s.config.driver = _tx.drv | ||||
| 	return s | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (s *Settings) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Settings(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(s.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("servername=") | ||||
| 	builder.WriteString(s.Servername) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("ownerid=") | ||||
| 	builder.WriteString(s.Ownerid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("permtoken=") | ||||
| 	builder.WriteString(s.Permtoken) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("apitoken=") | ||||
| 	builder.WriteString(s.Apitoken) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("statspagemode=") | ||||
| 	builder.WriteString(s.Statspagemode) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("loggerchannel=") | ||||
| 	builder.WriteString(s.Loggerchannel) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("spamchannel=") | ||||
| 	builder.WriteString(s.Spamchannel) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("greeterchannel=") | ||||
| 	builder.WriteString(s.Greeterchannel) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("greetermode=") | ||||
| 	builder.WriteString(s.Greetermode) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("announcechannel=") | ||||
| 	builder.WriteString(s.Announcechannel) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("logger=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Logger)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("spamprotection=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Spamprotection)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("linkprotection=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Linkprotection)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("wordfilter=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Wordfilter)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("greetings=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Greetings)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("apitoggle=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Apitoggle)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("moderation=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Moderation)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("automatedmoderation=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Automatedmoderation)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("twitchannounce=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Twitchannounce)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("twitterannounce=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Twitterannounce)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("music=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Music)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("statspage=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Statspage)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("statsprivate=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Statsprivate)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("stats=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", s.Stats)) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // SettingsSlice is a parsable slice of Settings. | ||||
| type SettingsSlice []*Settings | ||||
|  | ||||
| func (s SettingsSlice) config(cfg config) { | ||||
| 	for _i := range s { | ||||
| 		s[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										133
									
								
								ent/settings/settings.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										133
									
								
								ent/settings/settings.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,133 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package settings | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the settings type in the database. | ||||
| 	Label = "settings" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldServername holds the string denoting the servername field in the database. | ||||
| 	FieldServername = "servername" | ||||
| 	// FieldOwnerid holds the string denoting the ownerid field in the database. | ||||
| 	FieldOwnerid = "ownerid" | ||||
| 	// FieldPermtoken holds the string denoting the permtoken field in the database. | ||||
| 	FieldPermtoken = "permtoken" | ||||
| 	// FieldApitoken holds the string denoting the apitoken field in the database. | ||||
| 	FieldApitoken = "apitoken" | ||||
| 	// FieldStatspagemode holds the string denoting the statspagemode field in the database. | ||||
| 	FieldStatspagemode = "statspagemode" | ||||
| 	// FieldLoggerchannel holds the string denoting the loggerchannel field in the database. | ||||
| 	FieldLoggerchannel = "loggerchannel" | ||||
| 	// FieldSpamchannel holds the string denoting the spamchannel field in the database. | ||||
| 	FieldSpamchannel = "spamchannel" | ||||
| 	// FieldGreeterchannel holds the string denoting the greeterchannel field in the database. | ||||
| 	FieldGreeterchannel = "greeterchannel" | ||||
| 	// FieldGreetermode holds the string denoting the greetermode field in the database. | ||||
| 	FieldGreetermode = "greetermode" | ||||
| 	// FieldAnnouncechannel holds the string denoting the announcechannel field in the database. | ||||
| 	FieldAnnouncechannel = "announcechannel" | ||||
| 	// FieldLogger holds the string denoting the logger field in the database. | ||||
| 	FieldLogger = "logger" | ||||
| 	// FieldSpamprotection holds the string denoting the spamprotection field in the database. | ||||
| 	FieldSpamprotection = "spamprotection" | ||||
| 	// FieldLinkprotection holds the string denoting the linkprotection field in the database. | ||||
| 	FieldLinkprotection = "linkprotection" | ||||
| 	// FieldWordfilter holds the string denoting the wordfilter field in the database. | ||||
| 	FieldWordfilter = "wordfilter" | ||||
| 	// FieldGreetings holds the string denoting the greetings field in the database. | ||||
| 	FieldGreetings = "greetings" | ||||
| 	// FieldApitoggle holds the string denoting the apitoggle field in the database. | ||||
| 	FieldApitoggle = "apitoggle" | ||||
| 	// FieldModeration holds the string denoting the moderation field in the database. | ||||
| 	FieldModeration = "moderation" | ||||
| 	// FieldAutomatedmoderation holds the string denoting the automatedmoderation field in the database. | ||||
| 	FieldAutomatedmoderation = "automatedmoderation" | ||||
| 	// FieldTwitchannounce holds the string denoting the twitchannounce field in the database. | ||||
| 	FieldTwitchannounce = "twitchannounce" | ||||
| 	// FieldTwitterannounce holds the string denoting the twitterannounce field in the database. | ||||
| 	FieldTwitterannounce = "twitterannounce" | ||||
| 	// FieldMusic holds the string denoting the music field in the database. | ||||
| 	FieldMusic = "music" | ||||
| 	// FieldStatspage holds the string denoting the statspage field in the database. | ||||
| 	FieldStatspage = "statspage" | ||||
| 	// FieldStatsprivate holds the string denoting the statsprivate field in the database. | ||||
| 	FieldStatsprivate = "statsprivate" | ||||
| 	// FieldStats holds the string denoting the stats field in the database. | ||||
| 	FieldStats = "stats" | ||||
| 	// Table holds the table name of the settings in the database. | ||||
| 	Table = "settings" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for settings fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldServername, | ||||
| 	FieldOwnerid, | ||||
| 	FieldPermtoken, | ||||
| 	FieldApitoken, | ||||
| 	FieldStatspagemode, | ||||
| 	FieldLoggerchannel, | ||||
| 	FieldSpamchannel, | ||||
| 	FieldGreeterchannel, | ||||
| 	FieldGreetermode, | ||||
| 	FieldAnnouncechannel, | ||||
| 	FieldLogger, | ||||
| 	FieldSpamprotection, | ||||
| 	FieldLinkprotection, | ||||
| 	FieldWordfilter, | ||||
| 	FieldGreetings, | ||||
| 	FieldApitoggle, | ||||
| 	FieldModeration, | ||||
| 	FieldAutomatedmoderation, | ||||
| 	FieldTwitchannounce, | ||||
| 	FieldTwitterannounce, | ||||
| 	FieldMusic, | ||||
| 	FieldStatspage, | ||||
| 	FieldStatsprivate, | ||||
| 	FieldStats, | ||||
| } | ||||
|  | ||||
| // 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 ( | ||||
| 	// DefaultLogger holds the default value on creation for the "logger" field. | ||||
| 	DefaultLogger bool | ||||
| 	// DefaultSpamprotection holds the default value on creation for the "spamprotection" field. | ||||
| 	DefaultSpamprotection bool | ||||
| 	// DefaultLinkprotection holds the default value on creation for the "linkprotection" field. | ||||
| 	DefaultLinkprotection bool | ||||
| 	// DefaultWordfilter holds the default value on creation for the "wordfilter" field. | ||||
| 	DefaultWordfilter bool | ||||
| 	// DefaultGreetings holds the default value on creation for the "greetings" field. | ||||
| 	DefaultGreetings bool | ||||
| 	// DefaultApitoggle holds the default value on creation for the "apitoggle" field. | ||||
| 	DefaultApitoggle bool | ||||
| 	// DefaultModeration holds the default value on creation for the "moderation" field. | ||||
| 	DefaultModeration bool | ||||
| 	// DefaultAutomatedmoderation holds the default value on creation for the "automatedmoderation" field. | ||||
| 	DefaultAutomatedmoderation bool | ||||
| 	// DefaultTwitchannounce holds the default value on creation for the "twitchannounce" field. | ||||
| 	DefaultTwitchannounce bool | ||||
| 	// DefaultTwitterannounce holds the default value on creation for the "twitterannounce" field. | ||||
| 	DefaultTwitterannounce bool | ||||
| 	// DefaultMusic holds the default value on creation for the "music" field. | ||||
| 	DefaultMusic bool | ||||
| 	// DefaultStatspage holds the default value on creation for the "statspage" field. | ||||
| 	DefaultStatspage bool | ||||
| 	// DefaultStatsprivate holds the default value on creation for the "statsprivate" field. | ||||
| 	DefaultStatsprivate bool | ||||
| 	// DefaultStats holds the default value on creation for the "stats" field. | ||||
| 	DefaultStats bool | ||||
| ) | ||||
							
								
								
									
										1703
									
								
								ent/settings/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1703
									
								
								ent/settings/where.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										820
									
								
								ent/settings_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										820
									
								
								ent/settings_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,820 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| ) | ||||
|  | ||||
| // SettingsCreate is the builder for creating a Settings entity. | ||||
| type SettingsCreate struct { | ||||
| 	config | ||||
| 	mutation *SettingsMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (sc *SettingsCreate) SetServerid(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetServerid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetServername sets the "servername" field. | ||||
| func (sc *SettingsCreate) SetServername(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetServername(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetOwnerid sets the "ownerid" field. | ||||
| func (sc *SettingsCreate) SetOwnerid(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetOwnerid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetPermtoken sets the "permtoken" field. | ||||
| func (sc *SettingsCreate) SetPermtoken(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetPermtoken(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetApitoken sets the "apitoken" field. | ||||
| func (sc *SettingsCreate) SetApitoken(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetApitoken(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetStatspagemode sets the "statspagemode" field. | ||||
| func (sc *SettingsCreate) SetStatspagemode(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetStatspagemode(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetLoggerchannel sets the "loggerchannel" field. | ||||
| func (sc *SettingsCreate) SetLoggerchannel(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetLoggerchannel(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetSpamchannel sets the "spamchannel" field. | ||||
| func (sc *SettingsCreate) SetSpamchannel(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetSpamchannel(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetGreeterchannel sets the "greeterchannel" field. | ||||
| func (sc *SettingsCreate) SetGreeterchannel(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetGreeterchannel(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetGreetermode sets the "greetermode" field. | ||||
| func (sc *SettingsCreate) SetGreetermode(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetGreetermode(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetAnnouncechannel sets the "announcechannel" field. | ||||
| func (sc *SettingsCreate) SetAnnouncechannel(s string) *SettingsCreate { | ||||
| 	sc.mutation.SetAnnouncechannel(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetLogger sets the "logger" field. | ||||
| func (sc *SettingsCreate) SetLogger(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetLogger(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableLogger sets the "logger" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableLogger(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetLogger(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetSpamprotection sets the "spamprotection" field. | ||||
| func (sc *SettingsCreate) SetSpamprotection(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetSpamprotection(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableSpamprotection(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetSpamprotection(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetLinkprotection sets the "linkprotection" field. | ||||
| func (sc *SettingsCreate) SetLinkprotection(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetLinkprotection(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableLinkprotection(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetLinkprotection(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetWordfilter sets the "wordfilter" field. | ||||
| func (sc *SettingsCreate) SetWordfilter(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetWordfilter(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableWordfilter sets the "wordfilter" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableWordfilter(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetWordfilter(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetGreetings sets the "greetings" field. | ||||
| func (sc *SettingsCreate) SetGreetings(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetGreetings(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableGreetings sets the "greetings" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableGreetings(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetGreetings(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetApitoggle sets the "apitoggle" field. | ||||
| func (sc *SettingsCreate) SetApitoggle(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetApitoggle(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableApitoggle sets the "apitoggle" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableApitoggle(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetApitoggle(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetModeration sets the "moderation" field. | ||||
| func (sc *SettingsCreate) SetModeration(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetModeration(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableModeration sets the "moderation" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableModeration(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetModeration(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetAutomatedmoderation sets the "automatedmoderation" field. | ||||
| func (sc *SettingsCreate) SetAutomatedmoderation(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetAutomatedmoderation(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableAutomatedmoderation(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetAutomatedmoderation(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetTwitchannounce sets the "twitchannounce" field. | ||||
| func (sc *SettingsCreate) SetTwitchannounce(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetTwitchannounce(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableTwitchannounce(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetTwitchannounce(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetTwitterannounce sets the "twitterannounce" field. | ||||
| func (sc *SettingsCreate) SetTwitterannounce(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetTwitterannounce(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableTwitterannounce(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetTwitterannounce(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetMusic sets the "music" field. | ||||
| func (sc *SettingsCreate) SetMusic(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetMusic(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableMusic sets the "music" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableMusic(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetMusic(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetStatspage sets the "statspage" field. | ||||
| func (sc *SettingsCreate) SetStatspage(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetStatspage(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableStatspage sets the "statspage" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableStatspage(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetStatspage(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetStatsprivate sets the "statsprivate" field. | ||||
| func (sc *SettingsCreate) SetStatsprivate(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetStatsprivate(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableStatsprivate(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetStatsprivate(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetStats sets the "stats" field. | ||||
| func (sc *SettingsCreate) SetStats(b bool) *SettingsCreate { | ||||
| 	sc.mutation.SetStats(b) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetNillableStats sets the "stats" field if the given value is not nil. | ||||
| func (sc *SettingsCreate) SetNillableStats(b *bool) *SettingsCreate { | ||||
| 	if b != nil { | ||||
| 		sc.SetStats(*b) | ||||
| 	} | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (sc *SettingsCreate) SetID(i int) *SettingsCreate { | ||||
| 	sc.mutation.SetID(i) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // Mutation returns the SettingsMutation object of the builder. | ||||
| func (sc *SettingsCreate) Mutation() *SettingsMutation { | ||||
| 	return sc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Settings in the database. | ||||
| func (sc *SettingsCreate) Save(ctx context.Context) (*Settings, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Settings | ||||
| 	) | ||||
| 	sc.defaults() | ||||
| 	if len(sc.hooks) == 0 { | ||||
| 		if err = sc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = sc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SettingsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = sc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			sc.mutation = mutation | ||||
| 			if node, err = sc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(sc.hooks) - 1; i >= 0; i-- { | ||||
| 			if sc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, sc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Settings) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SettingsMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (sc *SettingsCreate) SaveX(ctx context.Context) *Settings { | ||||
| 	v, err := sc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (sc *SettingsCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := sc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sc *SettingsCreate) ExecX(ctx context.Context) { | ||||
| 	if err := sc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // defaults sets the default values of the builder before save. | ||||
| func (sc *SettingsCreate) defaults() { | ||||
| 	if _, ok := sc.mutation.Logger(); !ok { | ||||
| 		v := settings.DefaultLogger | ||||
| 		sc.mutation.SetLogger(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Spamprotection(); !ok { | ||||
| 		v := settings.DefaultSpamprotection | ||||
| 		sc.mutation.SetSpamprotection(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Linkprotection(); !ok { | ||||
| 		v := settings.DefaultLinkprotection | ||||
| 		sc.mutation.SetLinkprotection(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Wordfilter(); !ok { | ||||
| 		v := settings.DefaultWordfilter | ||||
| 		sc.mutation.SetWordfilter(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Greetings(); !ok { | ||||
| 		v := settings.DefaultGreetings | ||||
| 		sc.mutation.SetGreetings(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Apitoggle(); !ok { | ||||
| 		v := settings.DefaultApitoggle | ||||
| 		sc.mutation.SetApitoggle(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Moderation(); !ok { | ||||
| 		v := settings.DefaultModeration | ||||
| 		sc.mutation.SetModeration(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Automatedmoderation(); !ok { | ||||
| 		v := settings.DefaultAutomatedmoderation | ||||
| 		sc.mutation.SetAutomatedmoderation(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Twitchannounce(); !ok { | ||||
| 		v := settings.DefaultTwitchannounce | ||||
| 		sc.mutation.SetTwitchannounce(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Twitterannounce(); !ok { | ||||
| 		v := settings.DefaultTwitterannounce | ||||
| 		sc.mutation.SetTwitterannounce(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Music(); !ok { | ||||
| 		v := settings.DefaultMusic | ||||
| 		sc.mutation.SetMusic(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Statspage(); !ok { | ||||
| 		v := settings.DefaultStatspage | ||||
| 		sc.mutation.SetStatspage(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Statsprivate(); !ok { | ||||
| 		v := settings.DefaultStatsprivate | ||||
| 		sc.mutation.SetStatsprivate(v) | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Stats(); !ok { | ||||
| 		v := settings.DefaultStats | ||||
| 		sc.mutation.SetStats(v) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (sc *SettingsCreate) check() error { | ||||
| 	if _, ok := sc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Settings.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Servername(); !ok { | ||||
| 		return &ValidationError{Name: "servername", err: errors.New(`ent: missing required field "Settings.servername"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Ownerid(); !ok { | ||||
| 		return &ValidationError{Name: "ownerid", err: errors.New(`ent: missing required field "Settings.ownerid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Permtoken(); !ok { | ||||
| 		return &ValidationError{Name: "permtoken", err: errors.New(`ent: missing required field "Settings.permtoken"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Apitoken(); !ok { | ||||
| 		return &ValidationError{Name: "apitoken", err: errors.New(`ent: missing required field "Settings.apitoken"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Statspagemode(); !ok { | ||||
| 		return &ValidationError{Name: "statspagemode", err: errors.New(`ent: missing required field "Settings.statspagemode"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Loggerchannel(); !ok { | ||||
| 		return &ValidationError{Name: "loggerchannel", err: errors.New(`ent: missing required field "Settings.loggerchannel"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Spamchannel(); !ok { | ||||
| 		return &ValidationError{Name: "spamchannel", err: errors.New(`ent: missing required field "Settings.spamchannel"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Greeterchannel(); !ok { | ||||
| 		return &ValidationError{Name: "greeterchannel", err: errors.New(`ent: missing required field "Settings.greeterchannel"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Greetermode(); !ok { | ||||
| 		return &ValidationError{Name: "greetermode", err: errors.New(`ent: missing required field "Settings.greetermode"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Announcechannel(); !ok { | ||||
| 		return &ValidationError{Name: "announcechannel", err: errors.New(`ent: missing required field "Settings.announcechannel"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Logger(); !ok { | ||||
| 		return &ValidationError{Name: "logger", err: errors.New(`ent: missing required field "Settings.logger"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Spamprotection(); !ok { | ||||
| 		return &ValidationError{Name: "spamprotection", err: errors.New(`ent: missing required field "Settings.spamprotection"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Linkprotection(); !ok { | ||||
| 		return &ValidationError{Name: "linkprotection", err: errors.New(`ent: missing required field "Settings.linkprotection"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Wordfilter(); !ok { | ||||
| 		return &ValidationError{Name: "wordfilter", err: errors.New(`ent: missing required field "Settings.wordfilter"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Greetings(); !ok { | ||||
| 		return &ValidationError{Name: "greetings", err: errors.New(`ent: missing required field "Settings.greetings"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Apitoggle(); !ok { | ||||
| 		return &ValidationError{Name: "apitoggle", err: errors.New(`ent: missing required field "Settings.apitoggle"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Moderation(); !ok { | ||||
| 		return &ValidationError{Name: "moderation", err: errors.New(`ent: missing required field "Settings.moderation"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Automatedmoderation(); !ok { | ||||
| 		return &ValidationError{Name: "automatedmoderation", err: errors.New(`ent: missing required field "Settings.automatedmoderation"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Twitchannounce(); !ok { | ||||
| 		return &ValidationError{Name: "twitchannounce", err: errors.New(`ent: missing required field "Settings.twitchannounce"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Twitterannounce(); !ok { | ||||
| 		return &ValidationError{Name: "twitterannounce", err: errors.New(`ent: missing required field "Settings.twitterannounce"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Music(); !ok { | ||||
| 		return &ValidationError{Name: "music", err: errors.New(`ent: missing required field "Settings.music"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Statspage(); !ok { | ||||
| 		return &ValidationError{Name: "statspage", err: errors.New(`ent: missing required field "Settings.statspage"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Statsprivate(); !ok { | ||||
| 		return &ValidationError{Name: "statsprivate", err: errors.New(`ent: missing required field "Settings.statsprivate"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Stats(); !ok { | ||||
| 		return &ValidationError{Name: "stats", err: errors.New(`ent: missing required field "Settings.stats"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sc *SettingsCreate) sqlSave(ctx context.Context) (*Settings, error) { | ||||
| 	_node, _spec := sc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (sc *SettingsCreate) createSpec() (*Settings, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Settings{config: sc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: settings.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: settings.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := sc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Servername(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldServername, | ||||
| 		}) | ||||
| 		_node.Servername = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Ownerid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldOwnerid, | ||||
| 		}) | ||||
| 		_node.Ownerid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Permtoken(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldPermtoken, | ||||
| 		}) | ||||
| 		_node.Permtoken = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Apitoken(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldApitoken, | ||||
| 		}) | ||||
| 		_node.Apitoken = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Statspagemode(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldStatspagemode, | ||||
| 		}) | ||||
| 		_node.Statspagemode = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Loggerchannel(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldLoggerchannel, | ||||
| 		}) | ||||
| 		_node.Loggerchannel = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Spamchannel(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldSpamchannel, | ||||
| 		}) | ||||
| 		_node.Spamchannel = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Greeterchannel(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldGreeterchannel, | ||||
| 		}) | ||||
| 		_node.Greeterchannel = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Greetermode(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldGreetermode, | ||||
| 		}) | ||||
| 		_node.Greetermode = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Announcechannel(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldAnnouncechannel, | ||||
| 		}) | ||||
| 		_node.Announcechannel = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Logger(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldLogger, | ||||
| 		}) | ||||
| 		_node.Logger = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Spamprotection(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldSpamprotection, | ||||
| 		}) | ||||
| 		_node.Spamprotection = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Linkprotection(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldLinkprotection, | ||||
| 		}) | ||||
| 		_node.Linkprotection = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Wordfilter(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldWordfilter, | ||||
| 		}) | ||||
| 		_node.Wordfilter = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Greetings(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldGreetings, | ||||
| 		}) | ||||
| 		_node.Greetings = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Apitoggle(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldApitoggle, | ||||
| 		}) | ||||
| 		_node.Apitoggle = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Moderation(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldModeration, | ||||
| 		}) | ||||
| 		_node.Moderation = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Automatedmoderation(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldAutomatedmoderation, | ||||
| 		}) | ||||
| 		_node.Automatedmoderation = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Twitchannounce(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldTwitchannounce, | ||||
| 		}) | ||||
| 		_node.Twitchannounce = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Twitterannounce(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldTwitterannounce, | ||||
| 		}) | ||||
| 		_node.Twitterannounce = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Music(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldMusic, | ||||
| 		}) | ||||
| 		_node.Music = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Statspage(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldStatspage, | ||||
| 		}) | ||||
| 		_node.Statspage = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Statsprivate(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldStatsprivate, | ||||
| 		}) | ||||
| 		_node.Statsprivate = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Stats(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: settings.FieldStats, | ||||
| 		}) | ||||
| 		_node.Stats = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // SettingsCreateBulk is the builder for creating many Settings entities in bulk. | ||||
| type SettingsCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*SettingsCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Settings entities in the database. | ||||
| func (scb *SettingsCreateBulk) Save(ctx context.Context) ([]*Settings, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) | ||||
| 	nodes := make([]*Settings, len(scb.builders)) | ||||
| 	mutators := make([]Mutator, len(scb.builders)) | ||||
| 	for i := range scb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := scb.builders[i] | ||||
| 			builder.defaults() | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*SettingsMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, scb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, scb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (scb *SettingsCreateBulk) SaveX(ctx context.Context) []*Settings { | ||||
| 	v, err := scb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (scb *SettingsCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := scb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (scb *SettingsCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := scb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/settings_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/settings_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| ) | ||||
|  | ||||
| // SettingsDelete is the builder for deleting a Settings entity. | ||||
| type SettingsDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SettingsMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SettingsDelete builder. | ||||
| func (sd *SettingsDelete) Where(ps ...predicate.Settings) *SettingsDelete { | ||||
| 	sd.mutation.Where(ps...) | ||||
| 	return sd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (sd *SettingsDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(sd.hooks) == 0 { | ||||
| 		affected, err = sd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SettingsMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sd.mutation = mutation | ||||
| 			affected, err = sd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(sd.hooks) - 1; i >= 0; i-- { | ||||
| 			if sd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, sd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sd *SettingsDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := sd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (sd *SettingsDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: settings.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: settings.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := sd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SettingsDeleteOne is the builder for deleting a single Settings entity. | ||||
| type SettingsDeleteOne struct { | ||||
| 	sd *SettingsDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (sdo *SettingsDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := sdo.sd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{settings.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sdo *SettingsDeleteOne) ExecX(ctx context.Context) { | ||||
| 	sdo.sd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/settings_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/settings_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/settings" | ||||
| ) | ||||
|  | ||||
| // SettingsQuery is the builder for querying Settings entities. | ||||
| type SettingsQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Settings | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the SettingsQuery builder. | ||||
| func (sq *SettingsQuery) Where(ps ...predicate.Settings) *SettingsQuery { | ||||
| 	sq.predicates = append(sq.predicates, ps...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (sq *SettingsQuery) Limit(limit int) *SettingsQuery { | ||||
| 	sq.limit = &limit | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (sq *SettingsQuery) Offset(offset int) *SettingsQuery { | ||||
| 	sq.offset = &offset | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // 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 (sq *SettingsQuery) Unique(unique bool) *SettingsQuery { | ||||
| 	sq.unique = &unique | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (sq *SettingsQuery) Order(o ...OrderFunc) *SettingsQuery { | ||||
| 	sq.order = append(sq.order, o...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // First returns the first Settings entity from the query. | ||||
| // Returns a *NotFoundError when no Settings was found. | ||||
| func (sq *SettingsQuery) First(ctx context.Context) (*Settings, error) { | ||||
| 	nodes, err := sq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{settings.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) FirstX(ctx context.Context) *Settings { | ||||
| 	node, err := sq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Settings ID from the query. | ||||
| // Returns a *NotFoundError when no Settings ID was found. | ||||
| func (sq *SettingsQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{settings.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := sq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Settings entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Settings entity is found. | ||||
| // Returns a *NotFoundError when no Settings entities are found. | ||||
| func (sq *SettingsQuery) Only(ctx context.Context) (*Settings, error) { | ||||
| 	nodes, err := sq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{settings.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{settings.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) OnlyX(ctx context.Context) *Settings { | ||||
| 	node, err := sq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Settings ID in the query. | ||||
| // Returns a *NotSingularError when more than one Settings ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (sq *SettingsQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{settings.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{settings.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := sq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of SettingsSlice. | ||||
| func (sq *SettingsQuery) All(ctx context.Context) ([]*Settings, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return sq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) AllX(ctx context.Context) []*Settings { | ||||
| 	nodes, err := sq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Settings IDs. | ||||
| func (sq *SettingsQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := sq.Select(settings.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := sq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (sq *SettingsQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return sq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := sq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (sq *SettingsQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return sq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (sq *SettingsQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := sq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the SettingsQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (sq *SettingsQuery) Clone() *SettingsQuery { | ||||
| 	if sq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &SettingsQuery{ | ||||
| 		config:     sq.config, | ||||
| 		limit:      sq.limit, | ||||
| 		offset:     sq.offset, | ||||
| 		order:      append([]OrderFunc{}, sq.order...), | ||||
| 		predicates: append([]predicate.Settings{}, sq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    sq.sql.Clone(), | ||||
| 		path:   sq.path, | ||||
| 		unique: sq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Settings.Query(). | ||||
| //		GroupBy(settings.FieldServerid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SettingsQuery) GroupBy(field string, fields ...string) *SettingsGroupBy { | ||||
| 	grbuild := &SettingsGroupBy{config: sq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := sq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return sq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = settings.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Settings.Query(). | ||||
| //		Select(settings.FieldServerid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SettingsQuery) Select(fields ...string) *SettingsSelect { | ||||
| 	sq.fields = append(sq.fields, fields...) | ||||
| 	selbuild := &SettingsSelect{SettingsQuery: sq} | ||||
| 	selbuild.label = settings.Label | ||||
| 	selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range sq.fields { | ||||
| 		if !settings.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if sq.path != nil { | ||||
| 		prev, err := sq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		sq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Settings, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Settings{} | ||||
| 		_spec = sq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Settings).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Settings{config: sq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := sq.querySpec() | ||||
| 	_spec.Node.Columns = sq.fields | ||||
| 	if len(sq.fields) > 0 { | ||||
| 		_spec.Unique = sq.unique != nil && *sq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, sq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := sq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   settings.Table, | ||||
| 			Columns: settings.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: settings.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   sq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := sq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := sq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, settings.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != settings.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := sq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := sq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := sq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := sq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (sq *SettingsQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(sq.driver.Dialect()) | ||||
| 	t1 := builder.Table(settings.Table) | ||||
| 	columns := sq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = settings.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if sq.sql != nil { | ||||
| 		selector = sq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if sq.unique != nil && *sq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range sq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range sq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := sq.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 := sq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // SettingsGroupBy is the group-by builder for Settings entities. | ||||
| type SettingsGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (sgb *SettingsGroupBy) Aggregate(fns ...AggregateFunc) *SettingsGroupBy { | ||||
| 	sgb.fns = append(sgb.fns, fns...) | ||||
| 	return sgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (sgb *SettingsGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := sgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	sgb.sql = query | ||||
| 	return sgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SettingsGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range sgb.fields { | ||||
| 		if !settings.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := sgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := sgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SettingsGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := sgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(sgb.fns)) | ||||
| 	for _, fn := range sgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(sgb.fields)+len(sgb.fns)) | ||||
| 		for _, f := range sgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(sgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // SettingsSelect is the builder for selecting fields of Settings entities. | ||||
| type SettingsSelect struct { | ||||
| 	*SettingsQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ss *SettingsSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ss.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ss.sql = ss.SettingsQuery.sqlQuery(ctx) | ||||
| 	return ss.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ss *SettingsSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ss.sql.Query() | ||||
| 	if err := ss.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										1119
									
								
								ent/settings_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1119
									
								
								ent/settings_update.go
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										121
									
								
								ent/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										121
									
								
								ent/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,121 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| ) | ||||
|  | ||||
| // Socialmedia is the model entity for the Socialmedia schema. | ||||
| type Socialmedia struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Type holds the value of the "type" field. | ||||
| 	Type string `json:"type,omitempty"` | ||||
| 	// Identificator holds the value of the "identificator" field. | ||||
| 	Identificator string `json:"identificator,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Socialmedia) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case socialmedia.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case socialmedia.FieldServerid, socialmedia.FieldType, socialmedia.FieldIdentificator: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Socialmedia", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Socialmedia fields. | ||||
| func (s *Socialmedia) assignValues(columns []string, values []interface{}) 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 socialmedia.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			s.ID = int(value.Int64) | ||||
| 		case socialmedia.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Serverid = value.String | ||||
| 			} | ||||
| 		case socialmedia.FieldType: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field type", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Type = value.String | ||||
| 			} | ||||
| 		case socialmedia.FieldIdentificator: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field identificator", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Identificator = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Socialmedia. | ||||
| // Note that you need to call Socialmedia.Unwrap() before calling this method if this Socialmedia | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (s *Socialmedia) Update() *SocialmediaUpdateOne { | ||||
| 	return (&SocialmediaClient{config: s.config}).UpdateOne(s) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Socialmedia 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 (s *Socialmedia) Unwrap() *Socialmedia { | ||||
| 	_tx, ok := s.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Socialmedia is not a transactional entity") | ||||
| 	} | ||||
| 	s.config.driver = _tx.drv | ||||
| 	return s | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (s *Socialmedia) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Socialmedia(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(s.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("type=") | ||||
| 	builder.WriteString(s.Type) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("identificator=") | ||||
| 	builder.WriteString(s.Identificator) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // SocialmediaSlice is a parsable slice of Socialmedia. | ||||
| type SocialmediaSlice []*Socialmedia | ||||
|  | ||||
| func (s SocialmediaSlice) config(cfg config) { | ||||
| 	for _i := range s { | ||||
| 		s[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										36
									
								
								ent/socialmedia/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								ent/socialmedia/socialmedia.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package socialmedia | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the socialmedia type in the database. | ||||
| 	Label = "socialmedia" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldType holds the string denoting the type field in the database. | ||||
| 	FieldType = "type" | ||||
| 	// FieldIdentificator holds the string denoting the identificator field in the database. | ||||
| 	FieldIdentificator = "identificator" | ||||
| 	// Table holds the table name of the socialmedia in the database. | ||||
| 	Table = "socialmedia" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for socialmedia fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldType, | ||||
| 	FieldIdentificator, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										465
									
								
								ent/socialmedia/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										465
									
								
								ent/socialmedia/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,465 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package socialmedia | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Type applies equality check predicate on the "type" field. It's identical to TypeEQ. | ||||
| func Type(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Identificator applies equality check predicate on the "identificator" field. It's identical to IdentificatorEQ. | ||||
| func Identificator(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEQ applies the EQ predicate on the "type" field. | ||||
| func TypeEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNEQ applies the NEQ predicate on the "type" field. | ||||
| func TypeNEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeIn applies the In predicate on the "type" field. | ||||
| func TypeIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNotIn applies the NotIn predicate on the "type" field. | ||||
| func TypeNotIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGT applies the GT predicate on the "type" field. | ||||
| func TypeGT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGTE applies the GTE predicate on the "type" field. | ||||
| func TypeGTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLT applies the LT predicate on the "type" field. | ||||
| func TypeLT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLTE applies the LTE predicate on the "type" field. | ||||
| func TypeLTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContains applies the Contains predicate on the "type" field. | ||||
| func TypeContains(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasPrefix applies the HasPrefix predicate on the "type" field. | ||||
| func TypeHasPrefix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasSuffix applies the HasSuffix predicate on the "type" field. | ||||
| func TypeHasSuffix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEqualFold applies the EqualFold predicate on the "type" field. | ||||
| func TypeEqualFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContainsFold applies the ContainsFold predicate on the "type" field. | ||||
| func TypeContainsFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorEQ applies the EQ predicate on the "identificator" field. | ||||
| func IdentificatorEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorNEQ applies the NEQ predicate on the "identificator" field. | ||||
| func IdentificatorNEQ(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorIn applies the In predicate on the "identificator" field. | ||||
| func IdentificatorIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldIdentificator), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorNotIn applies the NotIn predicate on the "identificator" field. | ||||
| func IdentificatorNotIn(vs ...string) predicate.Socialmedia { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldIdentificator), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorGT applies the GT predicate on the "identificator" field. | ||||
| func IdentificatorGT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorGTE applies the GTE predicate on the "identificator" field. | ||||
| func IdentificatorGTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorLT applies the LT predicate on the "identificator" field. | ||||
| func IdentificatorLT(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorLTE applies the LTE predicate on the "identificator" field. | ||||
| func IdentificatorLTE(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorContains applies the Contains predicate on the "identificator" field. | ||||
| func IdentificatorContains(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorHasPrefix applies the HasPrefix predicate on the "identificator" field. | ||||
| func IdentificatorHasPrefix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorHasSuffix applies the HasSuffix predicate on the "identificator" field. | ||||
| func IdentificatorHasSuffix(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorEqualFold applies the EqualFold predicate on the "identificator" field. | ||||
| func IdentificatorEqualFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IdentificatorContainsFold applies the ContainsFold predicate on the "identificator" field. | ||||
| func IdentificatorContainsFold(v string) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldIdentificator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Socialmedia) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Socialmedia) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Socialmedia) predicate.Socialmedia { | ||||
| 	return predicate.Socialmedia(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										272
									
								
								ent/socialmedia_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										272
									
								
								ent/socialmedia_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,272 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| ) | ||||
|  | ||||
| // SocialmediaCreate is the builder for creating a Socialmedia entity. | ||||
| type SocialmediaCreate struct { | ||||
| 	config | ||||
| 	mutation *SocialmediaMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (sc *SocialmediaCreate) SetServerid(s string) *SocialmediaCreate { | ||||
| 	sc.mutation.SetServerid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (sc *SocialmediaCreate) SetType(s string) *SocialmediaCreate { | ||||
| 	sc.mutation.SetType(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetIdentificator sets the "identificator" field. | ||||
| func (sc *SocialmediaCreate) SetIdentificator(s string) *SocialmediaCreate { | ||||
| 	sc.mutation.SetIdentificator(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (sc *SocialmediaCreate) SetID(i int) *SocialmediaCreate { | ||||
| 	sc.mutation.SetID(i) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // Mutation returns the SocialmediaMutation object of the builder. | ||||
| func (sc *SocialmediaCreate) Mutation() *SocialmediaMutation { | ||||
| 	return sc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Socialmedia in the database. | ||||
| func (sc *SocialmediaCreate) Save(ctx context.Context) (*Socialmedia, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Socialmedia | ||||
| 	) | ||||
| 	if len(sc.hooks) == 0 { | ||||
| 		if err = sc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = sc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SocialmediaMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = sc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			sc.mutation = mutation | ||||
| 			if node, err = sc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(sc.hooks) - 1; i >= 0; i-- { | ||||
| 			if sc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, sc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Socialmedia) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SocialmediaMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (sc *SocialmediaCreate) SaveX(ctx context.Context) *Socialmedia { | ||||
| 	v, err := sc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (sc *SocialmediaCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := sc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sc *SocialmediaCreate) ExecX(ctx context.Context) { | ||||
| 	if err := sc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (sc *SocialmediaCreate) check() error { | ||||
| 	if _, ok := sc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Socialmedia.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.GetType(); !ok { | ||||
| 		return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Socialmedia.type"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Identificator(); !ok { | ||||
| 		return &ValidationError{Name: "identificator", err: errors.New(`ent: missing required field "Socialmedia.identificator"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sc *SocialmediaCreate) sqlSave(ctx context.Context) (*Socialmedia, error) { | ||||
| 	_node, _spec := sc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (sc *SocialmediaCreate) createSpec() (*Socialmedia, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Socialmedia{config: sc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: socialmedia.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: socialmedia.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := sc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.GetType(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldType, | ||||
| 		}) | ||||
| 		_node.Type = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Identificator(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldIdentificator, | ||||
| 		}) | ||||
| 		_node.Identificator = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // SocialmediaCreateBulk is the builder for creating many Socialmedia entities in bulk. | ||||
| type SocialmediaCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*SocialmediaCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Socialmedia entities in the database. | ||||
| func (scb *SocialmediaCreateBulk) Save(ctx context.Context) ([]*Socialmedia, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) | ||||
| 	nodes := make([]*Socialmedia, len(scb.builders)) | ||||
| 	mutators := make([]Mutator, len(scb.builders)) | ||||
| 	for i := range scb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := scb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*SocialmediaMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, scb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, scb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (scb *SocialmediaCreateBulk) SaveX(ctx context.Context) []*Socialmedia { | ||||
| 	v, err := scb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (scb *SocialmediaCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := scb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (scb *SocialmediaCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := scb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/socialmedia_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/socialmedia_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| ) | ||||
|  | ||||
| // SocialmediaDelete is the builder for deleting a Socialmedia entity. | ||||
| type SocialmediaDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SocialmediaMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SocialmediaDelete builder. | ||||
| func (sd *SocialmediaDelete) Where(ps ...predicate.Socialmedia) *SocialmediaDelete { | ||||
| 	sd.mutation.Where(ps...) | ||||
| 	return sd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (sd *SocialmediaDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(sd.hooks) == 0 { | ||||
| 		affected, err = sd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SocialmediaMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sd.mutation = mutation | ||||
| 			affected, err = sd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(sd.hooks) - 1; i >= 0; i-- { | ||||
| 			if sd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, sd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sd *SocialmediaDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := sd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (sd *SocialmediaDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: socialmedia.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: socialmedia.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := sd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SocialmediaDeleteOne is the builder for deleting a single Socialmedia entity. | ||||
| type SocialmediaDeleteOne struct { | ||||
| 	sd *SocialmediaDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (sdo *SocialmediaDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := sdo.sd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{socialmedia.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sdo *SocialmediaDeleteOne) ExecX(ctx context.Context) { | ||||
| 	sdo.sd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/socialmedia_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/socialmedia_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| ) | ||||
|  | ||||
| // SocialmediaQuery is the builder for querying Socialmedia entities. | ||||
| type SocialmediaQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Socialmedia | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the SocialmediaQuery builder. | ||||
| func (sq *SocialmediaQuery) Where(ps ...predicate.Socialmedia) *SocialmediaQuery { | ||||
| 	sq.predicates = append(sq.predicates, ps...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (sq *SocialmediaQuery) Limit(limit int) *SocialmediaQuery { | ||||
| 	sq.limit = &limit | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (sq *SocialmediaQuery) Offset(offset int) *SocialmediaQuery { | ||||
| 	sq.offset = &offset | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // 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 (sq *SocialmediaQuery) Unique(unique bool) *SocialmediaQuery { | ||||
| 	sq.unique = &unique | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (sq *SocialmediaQuery) Order(o ...OrderFunc) *SocialmediaQuery { | ||||
| 	sq.order = append(sq.order, o...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // First returns the first Socialmedia entity from the query. | ||||
| // Returns a *NotFoundError when no Socialmedia was found. | ||||
| func (sq *SocialmediaQuery) First(ctx context.Context) (*Socialmedia, error) { | ||||
| 	nodes, err := sq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{socialmedia.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) FirstX(ctx context.Context) *Socialmedia { | ||||
| 	node, err := sq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Socialmedia ID from the query. | ||||
| // Returns a *NotFoundError when no Socialmedia ID was found. | ||||
| func (sq *SocialmediaQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{socialmedia.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := sq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Socialmedia entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Socialmedia entity is found. | ||||
| // Returns a *NotFoundError when no Socialmedia entities are found. | ||||
| func (sq *SocialmediaQuery) Only(ctx context.Context) (*Socialmedia, error) { | ||||
| 	nodes, err := sq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{socialmedia.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{socialmedia.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) OnlyX(ctx context.Context) *Socialmedia { | ||||
| 	node, err := sq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Socialmedia ID in the query. | ||||
| // Returns a *NotSingularError when more than one Socialmedia ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (sq *SocialmediaQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{socialmedia.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{socialmedia.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := sq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of SocialmediaSlice. | ||||
| func (sq *SocialmediaQuery) All(ctx context.Context) ([]*Socialmedia, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return sq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) AllX(ctx context.Context) []*Socialmedia { | ||||
| 	nodes, err := sq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Socialmedia IDs. | ||||
| func (sq *SocialmediaQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := sq.Select(socialmedia.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := sq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (sq *SocialmediaQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return sq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := sq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (sq *SocialmediaQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return sq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (sq *SocialmediaQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := sq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the SocialmediaQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (sq *SocialmediaQuery) Clone() *SocialmediaQuery { | ||||
| 	if sq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &SocialmediaQuery{ | ||||
| 		config:     sq.config, | ||||
| 		limit:      sq.limit, | ||||
| 		offset:     sq.offset, | ||||
| 		order:      append([]OrderFunc{}, sq.order...), | ||||
| 		predicates: append([]predicate.Socialmedia{}, sq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    sq.sql.Clone(), | ||||
| 		path:   sq.path, | ||||
| 		unique: sq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Socialmedia.Query(). | ||||
| //		GroupBy(socialmedia.FieldServerid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SocialmediaQuery) GroupBy(field string, fields ...string) *SocialmediaGroupBy { | ||||
| 	grbuild := &SocialmediaGroupBy{config: sq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := sq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return sq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = socialmedia.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Serverid string `json:"serverid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Socialmedia.Query(). | ||||
| //		Select(socialmedia.FieldServerid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SocialmediaQuery) Select(fields ...string) *SocialmediaSelect { | ||||
| 	sq.fields = append(sq.fields, fields...) | ||||
| 	selbuild := &SocialmediaSelect{SocialmediaQuery: sq} | ||||
| 	selbuild.label = socialmedia.Label | ||||
| 	selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range sq.fields { | ||||
| 		if !socialmedia.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if sq.path != nil { | ||||
| 		prev, err := sq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		sq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Socialmedia, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Socialmedia{} | ||||
| 		_spec = sq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Socialmedia).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Socialmedia{config: sq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := sq.querySpec() | ||||
| 	_spec.Node.Columns = sq.fields | ||||
| 	if len(sq.fields) > 0 { | ||||
| 		_spec.Unique = sq.unique != nil && *sq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, sq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := sq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   socialmedia.Table, | ||||
| 			Columns: socialmedia.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: socialmedia.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   sq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := sq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := sq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, socialmedia.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != socialmedia.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := sq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := sq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := sq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := sq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (sq *SocialmediaQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(sq.driver.Dialect()) | ||||
| 	t1 := builder.Table(socialmedia.Table) | ||||
| 	columns := sq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = socialmedia.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if sq.sql != nil { | ||||
| 		selector = sq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if sq.unique != nil && *sq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range sq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range sq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := sq.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 := sq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // SocialmediaGroupBy is the group-by builder for Socialmedia entities. | ||||
| type SocialmediaGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (sgb *SocialmediaGroupBy) Aggregate(fns ...AggregateFunc) *SocialmediaGroupBy { | ||||
| 	sgb.fns = append(sgb.fns, fns...) | ||||
| 	return sgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (sgb *SocialmediaGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := sgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	sgb.sql = query | ||||
| 	return sgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SocialmediaGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range sgb.fields { | ||||
| 		if !socialmedia.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := sgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := sgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SocialmediaGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := sgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(sgb.fns)) | ||||
| 	for _, fn := range sgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(sgb.fields)+len(sgb.fns)) | ||||
| 		for _, f := range sgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(sgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // SocialmediaSelect is the builder for selecting fields of Socialmedia entities. | ||||
| type SocialmediaSelect struct { | ||||
| 	*SocialmediaQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ss *SocialmediaSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ss.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ss.sql = ss.SocialmediaQuery.sqlQuery(ctx) | ||||
| 	return ss.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ss *SocialmediaSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ss.sql.Query() | ||||
| 	if err := ss.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										323
									
								
								ent/socialmedia_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										323
									
								
								ent/socialmedia_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,323 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" | ||||
| ) | ||||
|  | ||||
| // SocialmediaUpdate is the builder for updating Socialmedia entities. | ||||
| type SocialmediaUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SocialmediaMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SocialmediaUpdate builder. | ||||
| func (su *SocialmediaUpdate) Where(ps ...predicate.Socialmedia) *SocialmediaUpdate { | ||||
| 	su.mutation.Where(ps...) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (su *SocialmediaUpdate) SetServerid(s string) *SocialmediaUpdate { | ||||
| 	su.mutation.SetServerid(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (su *SocialmediaUpdate) SetType(s string) *SocialmediaUpdate { | ||||
| 	su.mutation.SetType(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetIdentificator sets the "identificator" field. | ||||
| func (su *SocialmediaUpdate) SetIdentificator(s string) *SocialmediaUpdate { | ||||
| 	su.mutation.SetIdentificator(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // Mutation returns the SocialmediaMutation object of the builder. | ||||
| func (su *SocialmediaUpdate) Mutation() *SocialmediaMutation { | ||||
| 	return su.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (su *SocialmediaUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(su.hooks) == 0 { | ||||
| 		affected, err = su.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SocialmediaMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			su.mutation = mutation | ||||
| 			affected, err = su.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(su.hooks) - 1; i >= 0; i-- { | ||||
| 			if su.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = su.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, su.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (su *SocialmediaUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := su.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (su *SocialmediaUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := su.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (su *SocialmediaUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := su.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (su *SocialmediaUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   socialmedia.Table, | ||||
| 			Columns: socialmedia.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: socialmedia.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := su.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Identificator(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldIdentificator, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{socialmedia.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // SocialmediaUpdateOne is the builder for updating a single Socialmedia entity. | ||||
| type SocialmediaUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *SocialmediaMutation | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (suo *SocialmediaUpdateOne) SetServerid(s string) *SocialmediaUpdateOne { | ||||
| 	suo.mutation.SetServerid(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (suo *SocialmediaUpdateOne) SetType(s string) *SocialmediaUpdateOne { | ||||
| 	suo.mutation.SetType(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetIdentificator sets the "identificator" field. | ||||
| func (suo *SocialmediaUpdateOne) SetIdentificator(s string) *SocialmediaUpdateOne { | ||||
| 	suo.mutation.SetIdentificator(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Mutation returns the SocialmediaMutation object of the builder. | ||||
| func (suo *SocialmediaUpdateOne) Mutation() *SocialmediaMutation { | ||||
| 	return suo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (suo *SocialmediaUpdateOne) Select(field string, fields ...string) *SocialmediaUpdateOne { | ||||
| 	suo.fields = append([]string{field}, fields...) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Socialmedia entity. | ||||
| func (suo *SocialmediaUpdateOne) Save(ctx context.Context) (*Socialmedia, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Socialmedia | ||||
| 	) | ||||
| 	if len(suo.hooks) == 0 { | ||||
| 		node, err = suo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SocialmediaMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			suo.mutation = mutation | ||||
| 			node, err = suo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(suo.hooks) - 1; i >= 0; i-- { | ||||
| 			if suo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = suo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, suo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Socialmedia) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SocialmediaMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (suo *SocialmediaUpdateOne) SaveX(ctx context.Context) *Socialmedia { | ||||
| 	node, err := suo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (suo *SocialmediaUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := suo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (suo *SocialmediaUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := suo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (suo *SocialmediaUpdateOne) sqlSave(ctx context.Context) (_node *Socialmedia, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   socialmedia.Table, | ||||
| 			Columns: socialmedia.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: socialmedia.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := suo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Socialmedia.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := suo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, socialmedia.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !socialmedia.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != socialmedia.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := suo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Identificator(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: socialmedia.FieldIdentificator, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Socialmedia{config: suo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{socialmedia.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										154
									
								
								ent/support.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										154
									
								
								ent/support.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,154 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| ) | ||||
|  | ||||
| // Support is the model entity for the Support schema. | ||||
| type Support struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Refid holds the value of the "refid" field. | ||||
| 	Refid string `json:"refid,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Creator holds the value of the "creator" field. | ||||
| 	Creator string `json:"creator,omitempty"` | ||||
| 	// Status holds the value of the "status" field. | ||||
| 	Status string `json:"status,omitempty"` | ||||
| 	// Title holds the value of the "title" field. | ||||
| 	Title string `json:"title,omitempty"` | ||||
| 	// Description holds the value of the "description" field. | ||||
| 	Description string `json:"description,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*Support) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case support.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case support.FieldRefid, support.FieldServerid, support.FieldCreator, support.FieldStatus, support.FieldTitle, support.FieldDescription: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type Support", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the Support fields. | ||||
| func (s *Support) assignValues(columns []string, values []interface{}) 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 support.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			s.ID = int(value.Int64) | ||||
| 		case support.FieldRefid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field refid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Refid = value.String | ||||
| 			} | ||||
| 		case support.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Serverid = value.String | ||||
| 			} | ||||
| 		case support.FieldCreator: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field creator", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Creator = value.String | ||||
| 			} | ||||
| 		case support.FieldStatus: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field status", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Status = value.String | ||||
| 			} | ||||
| 		case support.FieldTitle: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field title", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Title = value.String | ||||
| 			} | ||||
| 		case support.FieldDescription: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field description", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				s.Description = value.String | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this Support. | ||||
| // Note that you need to call Support.Unwrap() before calling this method if this Support | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (s *Support) Update() *SupportUpdateOne { | ||||
| 	return (&SupportClient{config: s.config}).UpdateOne(s) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the Support 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 (s *Support) Unwrap() *Support { | ||||
| 	_tx, ok := s.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: Support is not a transactional entity") | ||||
| 	} | ||||
| 	s.config.driver = _tx.drv | ||||
| 	return s | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (s *Support) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("Support(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) | ||||
| 	builder.WriteString("refid=") | ||||
| 	builder.WriteString(s.Refid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(s.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("creator=") | ||||
| 	builder.WriteString(s.Creator) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("status=") | ||||
| 	builder.WriteString(s.Status) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("title=") | ||||
| 	builder.WriteString(s.Title) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("description=") | ||||
| 	builder.WriteString(s.Description) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // Supports is a parsable slice of Support. | ||||
| type Supports []*Support | ||||
|  | ||||
| func (s Supports) config(cfg config) { | ||||
| 	for _i := range s { | ||||
| 		s[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										45
									
								
								ent/support/support.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								ent/support/support.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,45 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package support | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the support type in the database. | ||||
| 	Label = "support" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldRefid holds the string denoting the refid field in the database. | ||||
| 	FieldRefid = "refid" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldCreator holds the string denoting the creator field in the database. | ||||
| 	FieldCreator = "creator" | ||||
| 	// FieldStatus holds the string denoting the status field in the database. | ||||
| 	FieldStatus = "status" | ||||
| 	// FieldTitle holds the string denoting the title field in the database. | ||||
| 	FieldTitle = "title" | ||||
| 	// FieldDescription holds the string denoting the description field in the database. | ||||
| 	FieldDescription = "description" | ||||
| 	// Table holds the table name of the support in the database. | ||||
| 	Table = "supports" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for support fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldRefid, | ||||
| 	FieldServerid, | ||||
| 	FieldCreator, | ||||
| 	FieldStatus, | ||||
| 	FieldTitle, | ||||
| 	FieldDescription, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										819
									
								
								ent/support/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										819
									
								
								ent/support/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,819 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package support | ||||
|  | ||||
| import ( | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Refid applies equality check predicate on the "refid" field. It's identical to RefidEQ. | ||||
| func Refid(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. | ||||
| func Serverid(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Creator applies equality check predicate on the "creator" field. It's identical to CreatorEQ. | ||||
| func Creator(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Status applies equality check predicate on the "status" field. It's identical to StatusEQ. | ||||
| func Status(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Title applies equality check predicate on the "title" field. It's identical to TitleEQ. | ||||
| func Title(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ. | ||||
| func Description(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEQ applies the EQ predicate on the "refid" field. | ||||
| func RefidEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNEQ applies the NEQ predicate on the "refid" field. | ||||
| func RefidNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidIn applies the In predicate on the "refid" field. | ||||
| func RefidIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNotIn applies the NotIn predicate on the "refid" field. | ||||
| func RefidNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGT applies the GT predicate on the "refid" field. | ||||
| func RefidGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGTE applies the GTE predicate on the "refid" field. | ||||
| func RefidGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLT applies the LT predicate on the "refid" field. | ||||
| func RefidLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLTE applies the LTE predicate on the "refid" field. | ||||
| func RefidLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContains applies the Contains predicate on the "refid" field. | ||||
| func RefidContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasPrefix applies the HasPrefix predicate on the "refid" field. | ||||
| func RefidHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasSuffix applies the HasSuffix predicate on the "refid" field. | ||||
| func RefidHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEqualFold applies the EqualFold predicate on the "refid" field. | ||||
| func RefidEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContainsFold applies the ContainsFold predicate on the "refid" field. | ||||
| func RefidContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEQ applies the EQ predicate on the "serverid" field. | ||||
| func ServeridEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNEQ applies the NEQ predicate on the "serverid" field. | ||||
| func ServeridNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridIn applies the In predicate on the "serverid" field. | ||||
| func ServeridIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridNotIn applies the NotIn predicate on the "serverid" field. | ||||
| func ServeridNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldServerid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGT applies the GT predicate on the "serverid" field. | ||||
| func ServeridGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridGTE applies the GTE predicate on the "serverid" field. | ||||
| func ServeridGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLT applies the LT predicate on the "serverid" field. | ||||
| func ServeridLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridLTE applies the LTE predicate on the "serverid" field. | ||||
| func ServeridLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContains applies the Contains predicate on the "serverid" field. | ||||
| func ServeridContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasPrefix applies the HasPrefix predicate on the "serverid" field. | ||||
| func ServeridHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridHasSuffix applies the HasSuffix predicate on the "serverid" field. | ||||
| func ServeridHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridEqualFold applies the EqualFold predicate on the "serverid" field. | ||||
| func ServeridEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // ServeridContainsFold applies the ContainsFold predicate on the "serverid" field. | ||||
| func ServeridContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldServerid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorEQ applies the EQ predicate on the "creator" field. | ||||
| func CreatorEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorNEQ applies the NEQ predicate on the "creator" field. | ||||
| func CreatorNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorIn applies the In predicate on the "creator" field. | ||||
| func CreatorIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldCreator), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorNotIn applies the NotIn predicate on the "creator" field. | ||||
| func CreatorNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldCreator), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorGT applies the GT predicate on the "creator" field. | ||||
| func CreatorGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorGTE applies the GTE predicate on the "creator" field. | ||||
| func CreatorGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorLT applies the LT predicate on the "creator" field. | ||||
| func CreatorLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorLTE applies the LTE predicate on the "creator" field. | ||||
| func CreatorLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorContains applies the Contains predicate on the "creator" field. | ||||
| func CreatorContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorHasPrefix applies the HasPrefix predicate on the "creator" field. | ||||
| func CreatorHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorHasSuffix applies the HasSuffix predicate on the "creator" field. | ||||
| func CreatorHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorEqualFold applies the EqualFold predicate on the "creator" field. | ||||
| func CreatorEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatorContainsFold applies the ContainsFold predicate on the "creator" field. | ||||
| func CreatorContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldCreator), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusEQ applies the EQ predicate on the "status" field. | ||||
| func StatusEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusNEQ applies the NEQ predicate on the "status" field. | ||||
| func StatusNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusIn applies the In predicate on the "status" field. | ||||
| func StatusIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldStatus), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusNotIn applies the NotIn predicate on the "status" field. | ||||
| func StatusNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldStatus), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusGT applies the GT predicate on the "status" field. | ||||
| func StatusGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusGTE applies the GTE predicate on the "status" field. | ||||
| func StatusGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusLT applies the LT predicate on the "status" field. | ||||
| func StatusLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusLTE applies the LTE predicate on the "status" field. | ||||
| func StatusLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusContains applies the Contains predicate on the "status" field. | ||||
| func StatusContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusHasPrefix applies the HasPrefix predicate on the "status" field. | ||||
| func StatusHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusHasSuffix applies the HasSuffix predicate on the "status" field. | ||||
| func StatusHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusEqualFold applies the EqualFold predicate on the "status" field. | ||||
| func StatusEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // StatusContainsFold applies the ContainsFold predicate on the "status" field. | ||||
| func StatusContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldStatus), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleEQ applies the EQ predicate on the "title" field. | ||||
| func TitleEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleNEQ applies the NEQ predicate on the "title" field. | ||||
| func TitleNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleIn applies the In predicate on the "title" field. | ||||
| func TitleIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldTitle), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleNotIn applies the NotIn predicate on the "title" field. | ||||
| func TitleNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldTitle), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleGT applies the GT predicate on the "title" field. | ||||
| func TitleGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleGTE applies the GTE predicate on the "title" field. | ||||
| func TitleGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleLT applies the LT predicate on the "title" field. | ||||
| func TitleLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleLTE applies the LTE predicate on the "title" field. | ||||
| func TitleLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleContains applies the Contains predicate on the "title" field. | ||||
| func TitleContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleHasPrefix applies the HasPrefix predicate on the "title" field. | ||||
| func TitleHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleHasSuffix applies the HasSuffix predicate on the "title" field. | ||||
| func TitleHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleEqualFold applies the EqualFold predicate on the "title" field. | ||||
| func TitleEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TitleContainsFold applies the ContainsFold predicate on the "title" field. | ||||
| func TitleContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldTitle), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionEQ applies the EQ predicate on the "description" field. | ||||
| func DescriptionEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionNEQ applies the NEQ predicate on the "description" field. | ||||
| func DescriptionNEQ(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionIn applies the In predicate on the "description" field. | ||||
| func DescriptionIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldDescription), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionNotIn applies the NotIn predicate on the "description" field. | ||||
| func DescriptionNotIn(vs ...string) predicate.Support { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldDescription), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionGT applies the GT predicate on the "description" field. | ||||
| func DescriptionGT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionGTE applies the GTE predicate on the "description" field. | ||||
| func DescriptionGTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionLT applies the LT predicate on the "description" field. | ||||
| func DescriptionLT(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionLTE applies the LTE predicate on the "description" field. | ||||
| func DescriptionLTE(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionContains applies the Contains predicate on the "description" field. | ||||
| func DescriptionContains(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionHasPrefix applies the HasPrefix predicate on the "description" field. | ||||
| func DescriptionHasPrefix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionHasSuffix applies the HasSuffix predicate on the "description" field. | ||||
| func DescriptionHasSuffix(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionEqualFold applies the EqualFold predicate on the "description" field. | ||||
| func DescriptionEqualFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // DescriptionContainsFold applies the ContainsFold predicate on the "description" field. | ||||
| func DescriptionContainsFold(v string) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldDescription), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.Support) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.Support) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.Support) predicate.Support { | ||||
| 	return predicate.Support(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										323
									
								
								ent/support_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										323
									
								
								ent/support_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,323 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| ) | ||||
|  | ||||
| // SupportCreate is the builder for creating a Support entity. | ||||
| type SupportCreate struct { | ||||
| 	config | ||||
| 	mutation *SupportMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (sc *SupportCreate) SetRefid(s string) *SupportCreate { | ||||
| 	sc.mutation.SetRefid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (sc *SupportCreate) SetServerid(s string) *SupportCreate { | ||||
| 	sc.mutation.SetServerid(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetCreator sets the "creator" field. | ||||
| func (sc *SupportCreate) SetCreator(s string) *SupportCreate { | ||||
| 	sc.mutation.SetCreator(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetStatus sets the "status" field. | ||||
| func (sc *SupportCreate) SetStatus(s string) *SupportCreate { | ||||
| 	sc.mutation.SetStatus(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetTitle sets the "title" field. | ||||
| func (sc *SupportCreate) SetTitle(s string) *SupportCreate { | ||||
| 	sc.mutation.SetTitle(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (sc *SupportCreate) SetDescription(s string) *SupportCreate { | ||||
| 	sc.mutation.SetDescription(s) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (sc *SupportCreate) SetID(i int) *SupportCreate { | ||||
| 	sc.mutation.SetID(i) | ||||
| 	return sc | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportMutation object of the builder. | ||||
| func (sc *SupportCreate) Mutation() *SupportMutation { | ||||
| 	return sc.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the Support in the database. | ||||
| func (sc *SupportCreate) Save(ctx context.Context) (*Support, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Support | ||||
| 	) | ||||
| 	if len(sc.hooks) == 0 { | ||||
| 		if err = sc.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = sc.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = sc.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			sc.mutation = mutation | ||||
| 			if node, err = sc.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(sc.hooks) - 1; i >= 0; i-- { | ||||
| 			if sc.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sc.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, sc.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Support) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SupportMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (sc *SupportCreate) SaveX(ctx context.Context) *Support { | ||||
| 	v, err := sc.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (sc *SupportCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := sc.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sc *SupportCreate) ExecX(ctx context.Context) { | ||||
| 	if err := sc.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (sc *SupportCreate) check() error { | ||||
| 	if _, ok := sc.mutation.Refid(); !ok { | ||||
| 		return &ValidationError{Name: "refid", err: errors.New(`ent: missing required field "Support.refid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Serverid(); !ok { | ||||
| 		return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Support.serverid"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Creator(); !ok { | ||||
| 		return &ValidationError{Name: "creator", err: errors.New(`ent: missing required field "Support.creator"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Status(); !ok { | ||||
| 		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "Support.status"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Title(); !ok { | ||||
| 		return &ValidationError{Name: "title", err: errors.New(`ent: missing required field "Support.title"`)} | ||||
| 	} | ||||
| 	if _, ok := sc.mutation.Description(); !ok { | ||||
| 		return &ValidationError{Name: "description", err: errors.New(`ent: missing required field "Support.description"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sc *SupportCreate) sqlSave(ctx context.Context) (*Support, error) { | ||||
| 	_node, _spec := sc.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (sc *SupportCreate) createSpec() (*Support, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &Support{config: sc.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: support.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: support.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := sc.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Refid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldRefid, | ||||
| 		}) | ||||
| 		_node.Refid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Serverid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldServerid, | ||||
| 		}) | ||||
| 		_node.Serverid = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Creator(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldCreator, | ||||
| 		}) | ||||
| 		_node.Creator = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Status(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldStatus, | ||||
| 		}) | ||||
| 		_node.Status = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Title(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldTitle, | ||||
| 		}) | ||||
| 		_node.Title = value | ||||
| 	} | ||||
| 	if value, ok := sc.mutation.Description(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldDescription, | ||||
| 		}) | ||||
| 		_node.Description = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // SupportCreateBulk is the builder for creating many Support entities in bulk. | ||||
| type SupportCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*SupportCreate | ||||
| } | ||||
|  | ||||
| // Save creates the Support entities in the database. | ||||
| func (scb *SupportCreateBulk) Save(ctx context.Context) ([]*Support, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) | ||||
| 	nodes := make([]*Support, len(scb.builders)) | ||||
| 	mutators := make([]Mutator, len(scb.builders)) | ||||
| 	for i := range scb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := scb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*SupportMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, scb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, scb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (scb *SupportCreateBulk) SaveX(ctx context.Context) []*Support { | ||||
| 	v, err := scb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (scb *SupportCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := scb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (scb *SupportCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := scb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/support_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/support_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| ) | ||||
|  | ||||
| // SupportDelete is the builder for deleting a Support entity. | ||||
| type SupportDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SupportDelete builder. | ||||
| func (sd *SupportDelete) Where(ps ...predicate.Support) *SupportDelete { | ||||
| 	sd.mutation.Where(ps...) | ||||
| 	return sd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (sd *SupportDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(sd.hooks) == 0 { | ||||
| 		affected, err = sd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sd.mutation = mutation | ||||
| 			affected, err = sd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(sd.hooks) - 1; i >= 0; i-- { | ||||
| 			if sd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, sd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sd *SupportDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := sd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (sd *SupportDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: support.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: support.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := sd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SupportDeleteOne is the builder for deleting a single Support entity. | ||||
| type SupportDeleteOne struct { | ||||
| 	sd *SupportDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (sdo *SupportDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := sdo.sd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{support.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sdo *SupportDeleteOne) ExecX(ctx context.Context) { | ||||
| 	sdo.sd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/support_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/support_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| ) | ||||
|  | ||||
| // SupportQuery is the builder for querying Support entities. | ||||
| type SupportQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.Support | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the SupportQuery builder. | ||||
| func (sq *SupportQuery) Where(ps ...predicate.Support) *SupportQuery { | ||||
| 	sq.predicates = append(sq.predicates, ps...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (sq *SupportQuery) Limit(limit int) *SupportQuery { | ||||
| 	sq.limit = &limit | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (sq *SupportQuery) Offset(offset int) *SupportQuery { | ||||
| 	sq.offset = &offset | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // 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 (sq *SupportQuery) Unique(unique bool) *SupportQuery { | ||||
| 	sq.unique = &unique | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (sq *SupportQuery) Order(o ...OrderFunc) *SupportQuery { | ||||
| 	sq.order = append(sq.order, o...) | ||||
| 	return sq | ||||
| } | ||||
|  | ||||
| // First returns the first Support entity from the query. | ||||
| // Returns a *NotFoundError when no Support was found. | ||||
| func (sq *SupportQuery) First(ctx context.Context) (*Support, error) { | ||||
| 	nodes, err := sq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{support.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (sq *SupportQuery) FirstX(ctx context.Context) *Support { | ||||
| 	node, err := sq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first Support ID from the query. | ||||
| // Returns a *NotFoundError when no Support ID was found. | ||||
| func (sq *SupportQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{support.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (sq *SupportQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := sq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single Support entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one Support entity is found. | ||||
| // Returns a *NotFoundError when no Support entities are found. | ||||
| func (sq *SupportQuery) Only(ctx context.Context) (*Support, error) { | ||||
| 	nodes, err := sq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{support.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{support.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (sq *SupportQuery) OnlyX(ctx context.Context) *Support { | ||||
| 	node, err := sq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only Support ID in the query. | ||||
| // Returns a *NotSingularError when more than one Support ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (sq *SupportQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = sq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{support.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{support.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (sq *SupportQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := sq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of Supports. | ||||
| func (sq *SupportQuery) All(ctx context.Context) ([]*Support, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return sq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (sq *SupportQuery) AllX(ctx context.Context) []*Support { | ||||
| 	nodes, err := sq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of Support IDs. | ||||
| func (sq *SupportQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := sq.Select(support.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (sq *SupportQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := sq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (sq *SupportQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return sq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (sq *SupportQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := sq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (sq *SupportQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := sq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return sq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (sq *SupportQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := sq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the SupportQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (sq *SupportQuery) Clone() *SupportQuery { | ||||
| 	if sq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &SupportQuery{ | ||||
| 		config:     sq.config, | ||||
| 		limit:      sq.limit, | ||||
| 		offset:     sq.offset, | ||||
| 		order:      append([]OrderFunc{}, sq.order...), | ||||
| 		predicates: append([]predicate.Support{}, sq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    sq.sql.Clone(), | ||||
| 		path:   sq.path, | ||||
| 		unique: sq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Support.Query(). | ||||
| //		GroupBy(support.FieldRefid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SupportQuery) GroupBy(field string, fields ...string) *SupportGroupBy { | ||||
| 	grbuild := &SupportGroupBy{config: sq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := sq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return sq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = support.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.Support.Query(). | ||||
| //		Select(support.FieldRefid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (sq *SupportQuery) Select(fields ...string) *SupportSelect { | ||||
| 	sq.fields = append(sq.fields, fields...) | ||||
| 	selbuild := &SupportSelect{SupportQuery: sq} | ||||
| 	selbuild.label = support.Label | ||||
| 	selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range sq.fields { | ||||
| 		if !support.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if sq.path != nil { | ||||
| 		prev, err := sq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		sq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Support, error) { | ||||
| 	var ( | ||||
| 		nodes = []*Support{} | ||||
| 		_spec = sq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*Support).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &Support{config: sq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := sq.querySpec() | ||||
| 	_spec.Node.Columns = sq.fields | ||||
| 	if len(sq.fields) > 0 { | ||||
| 		_spec.Unique = sq.unique != nil && *sq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, sq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := sq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   support.Table, | ||||
| 			Columns: support.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: support.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   sq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := sq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := sq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, support.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != support.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := sq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := sq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := sq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := sq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (sq *SupportQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(sq.driver.Dialect()) | ||||
| 	t1 := builder.Table(support.Table) | ||||
| 	columns := sq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = support.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if sq.sql != nil { | ||||
| 		selector = sq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if sq.unique != nil && *sq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range sq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range sq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := sq.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 := sq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // SupportGroupBy is the group-by builder for Support entities. | ||||
| type SupportGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (sgb *SupportGroupBy) Aggregate(fns ...AggregateFunc) *SupportGroupBy { | ||||
| 	sgb.fns = append(sgb.fns, fns...) | ||||
| 	return sgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (sgb *SupportGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := sgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	sgb.sql = query | ||||
| 	return sgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SupportGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range sgb.fields { | ||||
| 		if !support.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := sgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := sgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (sgb *SupportGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := sgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(sgb.fns)) | ||||
| 	for _, fn := range sgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(sgb.fields)+len(sgb.fns)) | ||||
| 		for _, f := range sgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(sgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // SupportSelect is the builder for selecting fields of Support entities. | ||||
| type SupportSelect struct { | ||||
| 	*SupportQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (ss *SupportSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := ss.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ss.sql = ss.SupportQuery.sqlQuery(ctx) | ||||
| 	return ss.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (ss *SupportSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := ss.sql.Query() | ||||
| 	if err := ss.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										401
									
								
								ent/support_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										401
									
								
								ent/support_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,401 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/support" | ||||
| ) | ||||
|  | ||||
| // SupportUpdate is the builder for updating Support entities. | ||||
| type SupportUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SupportUpdate builder. | ||||
| func (su *SupportUpdate) Where(ps ...predicate.Support) *SupportUpdate { | ||||
| 	su.mutation.Where(ps...) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (su *SupportUpdate) SetRefid(s string) *SupportUpdate { | ||||
| 	su.mutation.SetRefid(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (su *SupportUpdate) SetServerid(s string) *SupportUpdate { | ||||
| 	su.mutation.SetServerid(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetCreator sets the "creator" field. | ||||
| func (su *SupportUpdate) SetCreator(s string) *SupportUpdate { | ||||
| 	su.mutation.SetCreator(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetStatus sets the "status" field. | ||||
| func (su *SupportUpdate) SetStatus(s string) *SupportUpdate { | ||||
| 	su.mutation.SetStatus(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetTitle sets the "title" field. | ||||
| func (su *SupportUpdate) SetTitle(s string) *SupportUpdate { | ||||
| 	su.mutation.SetTitle(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (su *SupportUpdate) SetDescription(s string) *SupportUpdate { | ||||
| 	su.mutation.SetDescription(s) | ||||
| 	return su | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportMutation object of the builder. | ||||
| func (su *SupportUpdate) Mutation() *SupportMutation { | ||||
| 	return su.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (su *SupportUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(su.hooks) == 0 { | ||||
| 		affected, err = su.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			su.mutation = mutation | ||||
| 			affected, err = su.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(su.hooks) - 1; i >= 0; i-- { | ||||
| 			if su.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = su.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, su.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (su *SupportUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := su.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (su *SupportUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := su.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (su *SupportUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := su.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (su *SupportUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   support.Table, | ||||
| 			Columns: support.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: support.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := su.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Creator(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldCreator, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Status(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldStatus, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Title(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldTitle, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := su.mutation.Description(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldDescription, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{support.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // SupportUpdateOne is the builder for updating a single Support entity. | ||||
| type SupportUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportMutation | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (suo *SupportUpdateOne) SetRefid(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetRefid(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetServerid sets the "serverid" field. | ||||
| func (suo *SupportUpdateOne) SetServerid(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetServerid(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetCreator sets the "creator" field. | ||||
| func (suo *SupportUpdateOne) SetCreator(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetCreator(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetStatus sets the "status" field. | ||||
| func (suo *SupportUpdateOne) SetStatus(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetStatus(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetTitle sets the "title" field. | ||||
| func (suo *SupportUpdateOne) SetTitle(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetTitle(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // SetDescription sets the "description" field. | ||||
| func (suo *SupportUpdateOne) SetDescription(s string) *SupportUpdateOne { | ||||
| 	suo.mutation.SetDescription(s) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportMutation object of the builder. | ||||
| func (suo *SupportUpdateOne) Mutation() *SupportMutation { | ||||
| 	return suo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (suo *SupportUpdateOne) Select(field string, fields ...string) *SupportUpdateOne { | ||||
| 	suo.fields = append([]string{field}, fields...) | ||||
| 	return suo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated Support entity. | ||||
| func (suo *SupportUpdateOne) Save(ctx context.Context) (*Support, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *Support | ||||
| 	) | ||||
| 	if len(suo.hooks) == 0 { | ||||
| 		node, err = suo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			suo.mutation = mutation | ||||
| 			node, err = suo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(suo.hooks) - 1; i >= 0; i-- { | ||||
| 			if suo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = suo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, suo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*Support) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SupportMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (suo *SupportUpdateOne) SaveX(ctx context.Context) *Support { | ||||
| 	node, err := suo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (suo *SupportUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := suo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (suo *SupportUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := suo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (suo *SupportUpdateOne) sqlSave(ctx context.Context) (_node *Support, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   support.Table, | ||||
| 			Columns: support.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: support.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := suo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Support.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := suo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, support.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !support.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != support.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := suo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Serverid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldServerid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Creator(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldCreator, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Status(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldStatus, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Title(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldTitle, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := suo.mutation.Description(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: support.FieldDescription, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &Support{config: suo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{support.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										170
									
								
								ent/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										170
									
								
								ent/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,170 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| ) | ||||
|  | ||||
| // SupportResponse is the model entity for the SupportResponse schema. | ||||
| type SupportResponse struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Refid holds the value of the "refid" field. | ||||
| 	Refid string `json:"refid,omitempty"` | ||||
| 	// Writer holds the value of the "writer" field. | ||||
| 	Writer string `json:"writer,omitempty"` | ||||
| 	// Message holds the value of the "message" field. | ||||
| 	Message string `json:"message,omitempty"` | ||||
| 	// Type holds the value of the "type" field. | ||||
| 	Type string `json:"type,omitempty"` | ||||
| 	// Rtcchannel holds the value of the "rtcchannel" field. | ||||
| 	Rtcchannel string `json:"rtcchannel,omitempty"` | ||||
| 	// Isread holds the value of the "isread" field. | ||||
| 	Isread bool `json:"isread,omitempty"` | ||||
| 	// Created holds the value of the "created" field. | ||||
| 	Created time.Time `json:"created,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*SupportResponse) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case supportresponse.FieldIsread: | ||||
| 			values[i] = new(sql.NullBool) | ||||
| 		case supportresponse.FieldID: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case supportresponse.FieldRefid, supportresponse.FieldWriter, supportresponse.FieldMessage, supportresponse.FieldType, supportresponse.FieldRtcchannel: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		case supportresponse.FieldCreated: | ||||
| 			values[i] = new(sql.NullTime) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type SupportResponse", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the SupportResponse fields. | ||||
| func (sr *SupportResponse) assignValues(columns []string, values []interface{}) 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 supportresponse.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			sr.ID = int(value.Int64) | ||||
| 		case supportresponse.FieldRefid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field refid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Refid = value.String | ||||
| 			} | ||||
| 		case supportresponse.FieldWriter: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field writer", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Writer = value.String | ||||
| 			} | ||||
| 		case supportresponse.FieldMessage: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field message", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Message = value.String | ||||
| 			} | ||||
| 		case supportresponse.FieldType: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field type", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Type = value.String | ||||
| 			} | ||||
| 		case supportresponse.FieldRtcchannel: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field rtcchannel", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Rtcchannel = value.String | ||||
| 			} | ||||
| 		case supportresponse.FieldIsread: | ||||
| 			if value, ok := values[i].(*sql.NullBool); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field isread", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Isread = value.Bool | ||||
| 			} | ||||
| 		case supportresponse.FieldCreated: | ||||
| 			if value, ok := values[i].(*sql.NullTime); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field created", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				sr.Created = value.Time | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this SupportResponse. | ||||
| // Note that you need to call SupportResponse.Unwrap() before calling this method if this SupportResponse | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (sr *SupportResponse) Update() *SupportResponseUpdateOne { | ||||
| 	return (&SupportResponseClient{config: sr.config}).UpdateOne(sr) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the SupportResponse 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 (sr *SupportResponse) Unwrap() *SupportResponse { | ||||
| 	_tx, ok := sr.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: SupportResponse is not a transactional entity") | ||||
| 	} | ||||
| 	sr.config.driver = _tx.drv | ||||
| 	return sr | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (sr *SupportResponse) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("SupportResponse(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", sr.ID)) | ||||
| 	builder.WriteString("refid=") | ||||
| 	builder.WriteString(sr.Refid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("writer=") | ||||
| 	builder.WriteString(sr.Writer) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("message=") | ||||
| 	builder.WriteString(sr.Message) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("type=") | ||||
| 	builder.WriteString(sr.Type) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("rtcchannel=") | ||||
| 	builder.WriteString(sr.Rtcchannel) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("isread=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", sr.Isread)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("created=") | ||||
| 	builder.WriteString(sr.Created.Format(time.ANSIC)) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // SupportResponses is a parsable slice of SupportResponse. | ||||
| type SupportResponses []*SupportResponse | ||||
|  | ||||
| func (sr SupportResponses) config(cfg config) { | ||||
| 	for _i := range sr { | ||||
| 		sr[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										48
									
								
								ent/supportresponse/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								ent/supportresponse/supportresponse.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,48 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package supportresponse | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the supportresponse type in the database. | ||||
| 	Label = "support_response" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldRefid holds the string denoting the refid field in the database. | ||||
| 	FieldRefid = "refid" | ||||
| 	// FieldWriter holds the string denoting the writer field in the database. | ||||
| 	FieldWriter = "writer" | ||||
| 	// FieldMessage holds the string denoting the message field in the database. | ||||
| 	FieldMessage = "message" | ||||
| 	// FieldType holds the string denoting the type field in the database. | ||||
| 	FieldType = "type" | ||||
| 	// FieldRtcchannel holds the string denoting the rtcchannel field in the database. | ||||
| 	FieldRtcchannel = "rtcchannel" | ||||
| 	// FieldIsread holds the string denoting the isread field in the database. | ||||
| 	FieldIsread = "isread" | ||||
| 	// FieldCreated holds the string denoting the created field in the database. | ||||
| 	FieldCreated = "created" | ||||
| 	// Table holds the table name of the supportresponse in the database. | ||||
| 	Table = "support_responses" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for supportresponse fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldRefid, | ||||
| 	FieldWriter, | ||||
| 	FieldMessage, | ||||
| 	FieldType, | ||||
| 	FieldRtcchannel, | ||||
| 	FieldIsread, | ||||
| 	FieldCreated, | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| } | ||||
							
								
								
									
										807
									
								
								ent/supportresponse/where.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										807
									
								
								ent/supportresponse/where.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,807 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package supportresponse | ||||
|  | ||||
| import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| ) | ||||
|  | ||||
| // ID filters vertices based on their ID field. | ||||
| func ID(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDEQ applies the EQ predicate on the ID field. | ||||
| func IDEQ(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNEQ applies the NEQ predicate on the ID field. | ||||
| func IDNEQ(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDIn applies the In predicate on the ID field. | ||||
| func IDIn(ids ...int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDNotIn applies the NotIn predicate on the ID field. | ||||
| func IDNotIn(ids ...int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		v := make([]interface{}, len(ids)) | ||||
| 		for i := range v { | ||||
| 			v[i] = ids[i] | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldID), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGT applies the GT predicate on the ID field. | ||||
| func IDGT(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDGTE applies the GTE predicate on the ID field. | ||||
| func IDGTE(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLT applies the LT predicate on the ID field. | ||||
| func IDLT(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IDLTE applies the LTE predicate on the ID field. | ||||
| func IDLTE(id int) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldID), id)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Refid applies equality check predicate on the "refid" field. It's identical to RefidEQ. | ||||
| func Refid(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Writer applies equality check predicate on the "writer" field. It's identical to WriterEQ. | ||||
| func Writer(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Message applies equality check predicate on the "message" field. It's identical to MessageEQ. | ||||
| func Message(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Type applies equality check predicate on the "type" field. It's identical to TypeEQ. | ||||
| func Type(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Rtcchannel applies equality check predicate on the "rtcchannel" field. It's identical to RtcchannelEQ. | ||||
| func Rtcchannel(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Isread applies equality check predicate on the "isread" field. It's identical to IsreadEQ. | ||||
| func Isread(v bool) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIsread), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Created applies equality check predicate on the "created" field. It's identical to CreatedEQ. | ||||
| func Created(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEQ applies the EQ predicate on the "refid" field. | ||||
| func RefidEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNEQ applies the NEQ predicate on the "refid" field. | ||||
| func RefidNEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidIn applies the In predicate on the "refid" field. | ||||
| func RefidIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidNotIn applies the NotIn predicate on the "refid" field. | ||||
| func RefidNotIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldRefid), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGT applies the GT predicate on the "refid" field. | ||||
| func RefidGT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidGTE applies the GTE predicate on the "refid" field. | ||||
| func RefidGTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLT applies the LT predicate on the "refid" field. | ||||
| func RefidLT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidLTE applies the LTE predicate on the "refid" field. | ||||
| func RefidLTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContains applies the Contains predicate on the "refid" field. | ||||
| func RefidContains(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasPrefix applies the HasPrefix predicate on the "refid" field. | ||||
| func RefidHasPrefix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidHasSuffix applies the HasSuffix predicate on the "refid" field. | ||||
| func RefidHasSuffix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidEqualFold applies the EqualFold predicate on the "refid" field. | ||||
| func RefidEqualFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RefidContainsFold applies the ContainsFold predicate on the "refid" field. | ||||
| func RefidContainsFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldRefid), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterEQ applies the EQ predicate on the "writer" field. | ||||
| func WriterEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterNEQ applies the NEQ predicate on the "writer" field. | ||||
| func WriterNEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterIn applies the In predicate on the "writer" field. | ||||
| func WriterIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldWriter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterNotIn applies the NotIn predicate on the "writer" field. | ||||
| func WriterNotIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldWriter), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterGT applies the GT predicate on the "writer" field. | ||||
| func WriterGT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterGTE applies the GTE predicate on the "writer" field. | ||||
| func WriterGTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterLT applies the LT predicate on the "writer" field. | ||||
| func WriterLT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterLTE applies the LTE predicate on the "writer" field. | ||||
| func WriterLTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterContains applies the Contains predicate on the "writer" field. | ||||
| func WriterContains(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterHasPrefix applies the HasPrefix predicate on the "writer" field. | ||||
| func WriterHasPrefix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterHasSuffix applies the HasSuffix predicate on the "writer" field. | ||||
| func WriterHasSuffix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterEqualFold applies the EqualFold predicate on the "writer" field. | ||||
| func WriterEqualFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // WriterContainsFold applies the ContainsFold predicate on the "writer" field. | ||||
| func WriterContainsFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldWriter), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageEQ applies the EQ predicate on the "message" field. | ||||
| func MessageEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageNEQ applies the NEQ predicate on the "message" field. | ||||
| func MessageNEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageIn applies the In predicate on the "message" field. | ||||
| func MessageIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldMessage), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageNotIn applies the NotIn predicate on the "message" field. | ||||
| func MessageNotIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldMessage), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageGT applies the GT predicate on the "message" field. | ||||
| func MessageGT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageGTE applies the GTE predicate on the "message" field. | ||||
| func MessageGTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageLT applies the LT predicate on the "message" field. | ||||
| func MessageLT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageLTE applies the LTE predicate on the "message" field. | ||||
| func MessageLTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageContains applies the Contains predicate on the "message" field. | ||||
| func MessageContains(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageHasPrefix applies the HasPrefix predicate on the "message" field. | ||||
| func MessageHasPrefix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageHasSuffix applies the HasSuffix predicate on the "message" field. | ||||
| func MessageHasSuffix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageEqualFold applies the EqualFold predicate on the "message" field. | ||||
| func MessageEqualFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // MessageContainsFold applies the ContainsFold predicate on the "message" field. | ||||
| func MessageContainsFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldMessage), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEQ applies the EQ predicate on the "type" field. | ||||
| func TypeEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNEQ applies the NEQ predicate on the "type" field. | ||||
| func TypeNEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeIn applies the In predicate on the "type" field. | ||||
| func TypeIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeNotIn applies the NotIn predicate on the "type" field. | ||||
| func TypeNotIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldType), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGT applies the GT predicate on the "type" field. | ||||
| func TypeGT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeGTE applies the GTE predicate on the "type" field. | ||||
| func TypeGTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLT applies the LT predicate on the "type" field. | ||||
| func TypeLT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeLTE applies the LTE predicate on the "type" field. | ||||
| func TypeLTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContains applies the Contains predicate on the "type" field. | ||||
| func TypeContains(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasPrefix applies the HasPrefix predicate on the "type" field. | ||||
| func TypeHasPrefix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeHasSuffix applies the HasSuffix predicate on the "type" field. | ||||
| func TypeHasSuffix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeEqualFold applies the EqualFold predicate on the "type" field. | ||||
| func TypeEqualFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // TypeContainsFold applies the ContainsFold predicate on the "type" field. | ||||
| func TypeContainsFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldType), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelEQ applies the EQ predicate on the "rtcchannel" field. | ||||
| func RtcchannelEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelNEQ applies the NEQ predicate on the "rtcchannel" field. | ||||
| func RtcchannelNEQ(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelIn applies the In predicate on the "rtcchannel" field. | ||||
| func RtcchannelIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldRtcchannel), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelNotIn applies the NotIn predicate on the "rtcchannel" field. | ||||
| func RtcchannelNotIn(vs ...string) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldRtcchannel), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelGT applies the GT predicate on the "rtcchannel" field. | ||||
| func RtcchannelGT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelGTE applies the GTE predicate on the "rtcchannel" field. | ||||
| func RtcchannelGTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelLT applies the LT predicate on the "rtcchannel" field. | ||||
| func RtcchannelLT(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelLTE applies the LTE predicate on the "rtcchannel" field. | ||||
| func RtcchannelLTE(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelContains applies the Contains predicate on the "rtcchannel" field. | ||||
| func RtcchannelContains(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.Contains(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelHasPrefix applies the HasPrefix predicate on the "rtcchannel" field. | ||||
| func RtcchannelHasPrefix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasPrefix(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelHasSuffix applies the HasSuffix predicate on the "rtcchannel" field. | ||||
| func RtcchannelHasSuffix(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.HasSuffix(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelEqualFold applies the EqualFold predicate on the "rtcchannel" field. | ||||
| func RtcchannelEqualFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EqualFold(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // RtcchannelContainsFold applies the ContainsFold predicate on the "rtcchannel" field. | ||||
| func RtcchannelContainsFold(v string) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.ContainsFold(s.C(FieldRtcchannel), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IsreadEQ applies the EQ predicate on the "isread" field. | ||||
| func IsreadEQ(v bool) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldIsread), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // IsreadNEQ applies the NEQ predicate on the "isread" field. | ||||
| func IsreadNEQ(v bool) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldIsread), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedEQ applies the EQ predicate on the "created" field. | ||||
| func CreatedEQ(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.EQ(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedNEQ applies the NEQ predicate on the "created" field. | ||||
| func CreatedNEQ(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.NEQ(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedIn applies the In predicate on the "created" field. | ||||
| func CreatedIn(vs ...time.Time) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.In(s.C(FieldCreated), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedNotIn applies the NotIn predicate on the "created" field. | ||||
| func CreatedNotIn(vs ...time.Time) predicate.SupportResponse { | ||||
| 	v := make([]interface{}, len(vs)) | ||||
| 	for i := range v { | ||||
| 		v[i] = vs[i] | ||||
| 	} | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		// if not arguments were provided, append the FALSE constants, | ||||
| 		// since we can't apply "IN ()". This will make this predicate falsy. | ||||
| 		if len(v) == 0 { | ||||
| 			s.Where(sql.False()) | ||||
| 			return | ||||
| 		} | ||||
| 		s.Where(sql.NotIn(s.C(FieldCreated), v...)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedGT applies the GT predicate on the "created" field. | ||||
| func CreatedGT(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GT(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedGTE applies the GTE predicate on the "created" field. | ||||
| func CreatedGTE(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.GTE(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedLT applies the LT predicate on the "created" field. | ||||
| func CreatedLT(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LT(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // CreatedLTE applies the LTE predicate on the "created" field. | ||||
| func CreatedLTE(v time.Time) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s.Where(sql.LTE(s.C(FieldCreated), v)) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // And groups predicates with the AND operator between them. | ||||
| func And(predicates ...predicate.SupportResponse) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for _, p := range predicates { | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Or groups predicates with the OR operator between them. | ||||
| func Or(predicates ...predicate.SupportResponse) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		s1 := s.Clone().SetP(nil) | ||||
| 		for i, p := range predicates { | ||||
| 			if i > 0 { | ||||
| 				s1.Or() | ||||
| 			} | ||||
| 			p(s1) | ||||
| 		} | ||||
| 		s.Where(s1.P()) | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // Not applies the not operator on the given predicate. | ||||
| func Not(p predicate.SupportResponse) predicate.SupportResponse { | ||||
| 	return predicate.SupportResponse(func(s *sql.Selector) { | ||||
| 		p(s.Not()) | ||||
| 	}) | ||||
| } | ||||
							
								
								
									
										341
									
								
								ent/supportresponse_create.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										341
									
								
								ent/supportresponse_create.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,341 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"time" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| ) | ||||
|  | ||||
| // SupportResponseCreate is the builder for creating a SupportResponse entity. | ||||
| type SupportResponseCreate struct { | ||||
| 	config | ||||
| 	mutation *SupportResponseMutation | ||||
| 	hooks    []Hook | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (src *SupportResponseCreate) SetRefid(s string) *SupportResponseCreate { | ||||
| 	src.mutation.SetRefid(s) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetWriter sets the "writer" field. | ||||
| func (src *SupportResponseCreate) SetWriter(s string) *SupportResponseCreate { | ||||
| 	src.mutation.SetWriter(s) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetMessage sets the "message" field. | ||||
| func (src *SupportResponseCreate) SetMessage(s string) *SupportResponseCreate { | ||||
| 	src.mutation.SetMessage(s) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (src *SupportResponseCreate) SetType(s string) *SupportResponseCreate { | ||||
| 	src.mutation.SetType(s) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetRtcchannel sets the "rtcchannel" field. | ||||
| func (src *SupportResponseCreate) SetRtcchannel(s string) *SupportResponseCreate { | ||||
| 	src.mutation.SetRtcchannel(s) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetIsread sets the "isread" field. | ||||
| func (src *SupportResponseCreate) SetIsread(b bool) *SupportResponseCreate { | ||||
| 	src.mutation.SetIsread(b) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetCreated sets the "created" field. | ||||
| func (src *SupportResponseCreate) SetCreated(t time.Time) *SupportResponseCreate { | ||||
| 	src.mutation.SetCreated(t) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // SetID sets the "id" field. | ||||
| func (src *SupportResponseCreate) SetID(i int) *SupportResponseCreate { | ||||
| 	src.mutation.SetID(i) | ||||
| 	return src | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportResponseMutation object of the builder. | ||||
| func (src *SupportResponseCreate) Mutation() *SupportResponseMutation { | ||||
| 	return src.mutation | ||||
| } | ||||
|  | ||||
| // Save creates the SupportResponse in the database. | ||||
| func (src *SupportResponseCreate) Save(ctx context.Context) (*SupportResponse, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *SupportResponse | ||||
| 	) | ||||
| 	if len(src.hooks) == 0 { | ||||
| 		if err = src.check(); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		node, err = src.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportResponseMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			if err = src.check(); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			src.mutation = mutation | ||||
| 			if node, err = src.sqlSave(ctx); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
| 			mutation.id = &node.ID | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(src.hooks) - 1; i >= 0; i-- { | ||||
| 			if src.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = src.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, src.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*SupportResponse) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SupportResponseMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX calls Save and panics if Save returns an error. | ||||
| func (src *SupportResponseCreate) SaveX(ctx context.Context) *SupportResponse { | ||||
| 	v, err := src.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (src *SupportResponseCreate) Exec(ctx context.Context) error { | ||||
| 	_, err := src.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (src *SupportResponseCreate) ExecX(ctx context.Context) { | ||||
| 	if err := src.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // check runs all checks and user-defined validators on the builder. | ||||
| func (src *SupportResponseCreate) check() error { | ||||
| 	if _, ok := src.mutation.Refid(); !ok { | ||||
| 		return &ValidationError{Name: "refid", err: errors.New(`ent: missing required field "SupportResponse.refid"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.Writer(); !ok { | ||||
| 		return &ValidationError{Name: "writer", err: errors.New(`ent: missing required field "SupportResponse.writer"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.Message(); !ok { | ||||
| 		return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "SupportResponse.message"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.GetType(); !ok { | ||||
| 		return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "SupportResponse.type"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.Rtcchannel(); !ok { | ||||
| 		return &ValidationError{Name: "rtcchannel", err: errors.New(`ent: missing required field "SupportResponse.rtcchannel"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.Isread(); !ok { | ||||
| 		return &ValidationError{Name: "isread", err: errors.New(`ent: missing required field "SupportResponse.isread"`)} | ||||
| 	} | ||||
| 	if _, ok := src.mutation.Created(); !ok { | ||||
| 		return &ValidationError{Name: "created", err: errors.New(`ent: missing required field "SupportResponse.created"`)} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (src *SupportResponseCreate) sqlSave(ctx context.Context) (*SupportResponse, error) { | ||||
| 	_node, _spec := src.createSpec() | ||||
| 	if err := sqlgraph.CreateNode(ctx, src.driver, _spec); err != nil { | ||||
| 		if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if _spec.ID.Value != _node.ID { | ||||
| 		id := _spec.ID.Value.(int64) | ||||
| 		_node.ID = int(id) | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
|  | ||||
| func (src *SupportResponseCreate) createSpec() (*SupportResponse, *sqlgraph.CreateSpec) { | ||||
| 	var ( | ||||
| 		_node = &SupportResponse{config: src.config} | ||||
| 		_spec = &sqlgraph.CreateSpec{ | ||||
| 			Table: supportresponse.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: supportresponse.FieldID, | ||||
| 			}, | ||||
| 		} | ||||
| 	) | ||||
| 	if id, ok := src.mutation.ID(); ok { | ||||
| 		_node.ID = id | ||||
| 		_spec.ID.Value = id | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Refid(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRefid, | ||||
| 		}) | ||||
| 		_node.Refid = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Writer(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldWriter, | ||||
| 		}) | ||||
| 		_node.Writer = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Message(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldMessage, | ||||
| 		}) | ||||
| 		_node.Message = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.GetType(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldType, | ||||
| 		}) | ||||
| 		_node.Type = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Rtcchannel(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRtcchannel, | ||||
| 		}) | ||||
| 		_node.Rtcchannel = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Isread(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldIsread, | ||||
| 		}) | ||||
| 		_node.Isread = value | ||||
| 	} | ||||
| 	if value, ok := src.mutation.Created(); ok { | ||||
| 		_spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeTime, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldCreated, | ||||
| 		}) | ||||
| 		_node.Created = value | ||||
| 	} | ||||
| 	return _node, _spec | ||||
| } | ||||
|  | ||||
| // SupportResponseCreateBulk is the builder for creating many SupportResponse entities in bulk. | ||||
| type SupportResponseCreateBulk struct { | ||||
| 	config | ||||
| 	builders []*SupportResponseCreate | ||||
| } | ||||
|  | ||||
| // Save creates the SupportResponse entities in the database. | ||||
| func (srcb *SupportResponseCreateBulk) Save(ctx context.Context) ([]*SupportResponse, error) { | ||||
| 	specs := make([]*sqlgraph.CreateSpec, len(srcb.builders)) | ||||
| 	nodes := make([]*SupportResponse, len(srcb.builders)) | ||||
| 	mutators := make([]Mutator, len(srcb.builders)) | ||||
| 	for i := range srcb.builders { | ||||
| 		func(i int, root context.Context) { | ||||
| 			builder := srcb.builders[i] | ||||
| 			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 				mutation, ok := m.(*SupportResponseMutation) | ||||
| 				if !ok { | ||||
| 					return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 				} | ||||
| 				if err := builder.check(); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
| 				builder.mutation = mutation | ||||
| 				nodes[i], specs[i] = builder.createSpec() | ||||
| 				var err error | ||||
| 				if i < len(mutators)-1 { | ||||
| 					_, err = mutators[i+1].Mutate(root, srcb.builders[i+1].mutation) | ||||
| 				} else { | ||||
| 					spec := &sqlgraph.BatchCreateSpec{Nodes: specs} | ||||
| 					// Invoke the actual operation on the latest mutation in the chain. | ||||
| 					if err = sqlgraph.BatchCreate(ctx, srcb.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 && nodes[i].ID == 0 { | ||||
| 					id := specs[i].ID.Value.(int64) | ||||
| 					nodes[i].ID = int(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, srcb.builders[0].mutation); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (srcb *SupportResponseCreateBulk) SaveX(ctx context.Context) []*SupportResponse { | ||||
| 	v, err := srcb.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return v | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (srcb *SupportResponseCreateBulk) Exec(ctx context.Context) error { | ||||
| 	_, err := srcb.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (srcb *SupportResponseCreateBulk) ExecX(ctx context.Context) { | ||||
| 	if err := srcb.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										115
									
								
								ent/supportresponse_delete.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										115
									
								
								ent/supportresponse_delete.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,115 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| ) | ||||
|  | ||||
| // SupportResponseDelete is the builder for deleting a SupportResponse entity. | ||||
| type SupportResponseDelete struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportResponseMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SupportResponseDelete builder. | ||||
| func (srd *SupportResponseDelete) Where(ps ...predicate.SupportResponse) *SupportResponseDelete { | ||||
| 	srd.mutation.Where(ps...) | ||||
| 	return srd | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query and returns how many vertices were deleted. | ||||
| func (srd *SupportResponseDelete) Exec(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(srd.hooks) == 0 { | ||||
| 		affected, err = srd.sqlExec(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportResponseMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			srd.mutation = mutation | ||||
| 			affected, err = srd.sqlExec(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(srd.hooks) - 1; i >= 0; i-- { | ||||
| 			if srd.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = srd.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, srd.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (srd *SupportResponseDelete) ExecX(ctx context.Context) int { | ||||
| 	n, err := srd.Exec(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (srd *SupportResponseDelete) sqlExec(ctx context.Context) (int, error) { | ||||
| 	_spec := &sqlgraph.DeleteSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table: supportresponse.Table, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: supportresponse.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := srd.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	affected, err := sqlgraph.DeleteNodes(ctx, srd.driver, _spec) | ||||
| 	if err != nil && sqlgraph.IsConstraintError(err) { | ||||
| 		err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SupportResponseDeleteOne is the builder for deleting a single SupportResponse entity. | ||||
| type SupportResponseDeleteOne struct { | ||||
| 	srd *SupportResponseDelete | ||||
| } | ||||
|  | ||||
| // Exec executes the deletion query. | ||||
| func (srdo *SupportResponseDeleteOne) Exec(ctx context.Context) error { | ||||
| 	n, err := srdo.srd.Exec(ctx) | ||||
| 	switch { | ||||
| 	case err != nil: | ||||
| 		return err | ||||
| 	case n == 0: | ||||
| 		return &NotFoundError{supportresponse.Label} | ||||
| 	default: | ||||
| 		return nil | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (srdo *SupportResponseDeleteOne) ExecX(ctx context.Context) { | ||||
| 	srdo.srd.ExecX(ctx) | ||||
| } | ||||
							
								
								
									
										528
									
								
								ent/supportresponse_query.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										528
									
								
								ent/supportresponse_query.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,528 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"math" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"entgo.io/ent/dialect/sql/sqlgraph" | ||||
| 	"entgo.io/ent/schema/field" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| ) | ||||
|  | ||||
| // SupportResponseQuery is the builder for querying SupportResponse entities. | ||||
| type SupportResponseQuery struct { | ||||
| 	config | ||||
| 	limit      *int | ||||
| 	offset     *int | ||||
| 	unique     *bool | ||||
| 	order      []OrderFunc | ||||
| 	fields     []string | ||||
| 	predicates []predicate.SupportResponse | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Where adds a new predicate for the SupportResponseQuery builder. | ||||
| func (srq *SupportResponseQuery) Where(ps ...predicate.SupportResponse) *SupportResponseQuery { | ||||
| 	srq.predicates = append(srq.predicates, ps...) | ||||
| 	return srq | ||||
| } | ||||
|  | ||||
| // Limit adds a limit step to the query. | ||||
| func (srq *SupportResponseQuery) Limit(limit int) *SupportResponseQuery { | ||||
| 	srq.limit = &limit | ||||
| 	return srq | ||||
| } | ||||
|  | ||||
| // Offset adds an offset step to the query. | ||||
| func (srq *SupportResponseQuery) Offset(offset int) *SupportResponseQuery { | ||||
| 	srq.offset = &offset | ||||
| 	return srq | ||||
| } | ||||
|  | ||||
| // 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 (srq *SupportResponseQuery) Unique(unique bool) *SupportResponseQuery { | ||||
| 	srq.unique = &unique | ||||
| 	return srq | ||||
| } | ||||
|  | ||||
| // Order adds an order step to the query. | ||||
| func (srq *SupportResponseQuery) Order(o ...OrderFunc) *SupportResponseQuery { | ||||
| 	srq.order = append(srq.order, o...) | ||||
| 	return srq | ||||
| } | ||||
|  | ||||
| // First returns the first SupportResponse entity from the query. | ||||
| // Returns a *NotFoundError when no SupportResponse was found. | ||||
| func (srq *SupportResponseQuery) First(ctx context.Context) (*SupportResponse, error) { | ||||
| 	nodes, err := srq.Limit(1).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nil, &NotFoundError{supportresponse.Label} | ||||
| 	} | ||||
| 	return nodes[0], nil | ||||
| } | ||||
|  | ||||
| // FirstX is like First, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) FirstX(ctx context.Context) *SupportResponse { | ||||
| 	node, err := srq.First(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // FirstID returns the first SupportResponse ID from the query. | ||||
| // Returns a *NotFoundError when no SupportResponse ID was found. | ||||
| func (srq *SupportResponseQuery) FirstID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = srq.Limit(1).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	if len(ids) == 0 { | ||||
| 		err = &NotFoundError{supportresponse.Label} | ||||
| 		return | ||||
| 	} | ||||
| 	return ids[0], nil | ||||
| } | ||||
|  | ||||
| // FirstIDX is like FirstID, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) FirstIDX(ctx context.Context) int { | ||||
| 	id, err := srq.FirstID(ctx) | ||||
| 	if err != nil && !IsNotFound(err) { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // Only returns a single SupportResponse entity found by the query, ensuring it only returns one. | ||||
| // Returns a *NotSingularError when more than one SupportResponse entity is found. | ||||
| // Returns a *NotFoundError when no SupportResponse entities are found. | ||||
| func (srq *SupportResponseQuery) Only(ctx context.Context) (*SupportResponse, error) { | ||||
| 	nodes, err := srq.Limit(2).All(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	switch len(nodes) { | ||||
| 	case 1: | ||||
| 		return nodes[0], nil | ||||
| 	case 0: | ||||
| 		return nil, &NotFoundError{supportresponse.Label} | ||||
| 	default: | ||||
| 		return nil, &NotSingularError{supportresponse.Label} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // OnlyX is like Only, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) OnlyX(ctx context.Context) *SupportResponse { | ||||
| 	node, err := srq.Only(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // OnlyID is like Only, but returns the only SupportResponse ID in the query. | ||||
| // Returns a *NotSingularError when more than one SupportResponse ID is found. | ||||
| // Returns a *NotFoundError when no entities are found. | ||||
| func (srq *SupportResponseQuery) OnlyID(ctx context.Context) (id int, err error) { | ||||
| 	var ids []int | ||||
| 	if ids, err = srq.Limit(2).IDs(ctx); err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	switch len(ids) { | ||||
| 	case 1: | ||||
| 		id = ids[0] | ||||
| 	case 0: | ||||
| 		err = &NotFoundError{supportresponse.Label} | ||||
| 	default: | ||||
| 		err = &NotSingularError{supportresponse.Label} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // OnlyIDX is like OnlyID, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) OnlyIDX(ctx context.Context) int { | ||||
| 	id, err := srq.OnlyID(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| // All executes the query and returns a list of SupportResponses. | ||||
| func (srq *SupportResponseQuery) All(ctx context.Context) ([]*SupportResponse, error) { | ||||
| 	if err := srq.prepareQuery(ctx); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return srq.sqlAll(ctx) | ||||
| } | ||||
|  | ||||
| // AllX is like All, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) AllX(ctx context.Context) []*SupportResponse { | ||||
| 	nodes, err := srq.All(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return nodes | ||||
| } | ||||
|  | ||||
| // IDs executes the query and returns a list of SupportResponse IDs. | ||||
| func (srq *SupportResponseQuery) IDs(ctx context.Context) ([]int, error) { | ||||
| 	var ids []int | ||||
| 	if err := srq.Select(supportresponse.FieldID).Scan(ctx, &ids); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return ids, nil | ||||
| } | ||||
|  | ||||
| // IDsX is like IDs, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) IDsX(ctx context.Context) []int { | ||||
| 	ids, err := srq.IDs(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return ids | ||||
| } | ||||
|  | ||||
| // Count returns the count of the given query. | ||||
| func (srq *SupportResponseQuery) Count(ctx context.Context) (int, error) { | ||||
| 	if err := srq.prepareQuery(ctx); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return srq.sqlCount(ctx) | ||||
| } | ||||
|  | ||||
| // CountX is like Count, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) CountX(ctx context.Context) int { | ||||
| 	count, err := srq.Count(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return count | ||||
| } | ||||
|  | ||||
| // Exist returns true if the query has elements in the graph. | ||||
| func (srq *SupportResponseQuery) Exist(ctx context.Context) (bool, error) { | ||||
| 	if err := srq.prepareQuery(ctx); err != nil { | ||||
| 		return false, err | ||||
| 	} | ||||
| 	return srq.sqlExist(ctx) | ||||
| } | ||||
|  | ||||
| // ExistX is like Exist, but panics if an error occurs. | ||||
| func (srq *SupportResponseQuery) ExistX(ctx context.Context) bool { | ||||
| 	exist, err := srq.Exist(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return exist | ||||
| } | ||||
|  | ||||
| // Clone returns a duplicate of the SupportResponseQuery builder, including all associated steps. It can be | ||||
| // used to prepare common query builders and use them differently after the clone is made. | ||||
| func (srq *SupportResponseQuery) Clone() *SupportResponseQuery { | ||||
| 	if srq == nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &SupportResponseQuery{ | ||||
| 		config:     srq.config, | ||||
| 		limit:      srq.limit, | ||||
| 		offset:     srq.offset, | ||||
| 		order:      append([]OrderFunc{}, srq.order...), | ||||
| 		predicates: append([]predicate.SupportResponse{}, srq.predicates...), | ||||
| 		// clone intermediate query. | ||||
| 		sql:    srq.sql.Clone(), | ||||
| 		path:   srq.path, | ||||
| 		unique: srq.unique, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //		Count int `json:"count,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.SupportResponse.Query(). | ||||
| //		GroupBy(supportresponse.FieldRefid). | ||||
| //		Aggregate(ent.Count()). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (srq *SupportResponseQuery) GroupBy(field string, fields ...string) *SupportResponseGroupBy { | ||||
| 	grbuild := &SupportResponseGroupBy{config: srq.config} | ||||
| 	grbuild.fields = append([]string{field}, fields...) | ||||
| 	grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { | ||||
| 		if err := srq.prepareQuery(ctx); err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return srq.sqlQuery(ctx), nil | ||||
| 	} | ||||
| 	grbuild.label = supportresponse.Label | ||||
| 	grbuild.flds, grbuild.scan = &grbuild.fields, 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 { | ||||
| //		Refid string `json:"refid,omitempty"` | ||||
| //	} | ||||
| // | ||||
| //	client.SupportResponse.Query(). | ||||
| //		Select(supportresponse.FieldRefid). | ||||
| //		Scan(ctx, &v) | ||||
| // | ||||
| func (srq *SupportResponseQuery) Select(fields ...string) *SupportResponseSelect { | ||||
| 	srq.fields = append(srq.fields, fields...) | ||||
| 	selbuild := &SupportResponseSelect{SupportResponseQuery: srq} | ||||
| 	selbuild.label = supportresponse.Label | ||||
| 	selbuild.flds, selbuild.scan = &srq.fields, selbuild.Scan | ||||
| 	return selbuild | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) prepareQuery(ctx context.Context) error { | ||||
| 	for _, f := range srq.fields { | ||||
| 		if !supportresponse.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	if srq.path != nil { | ||||
| 		prev, err := srq.path(ctx) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		srq.sql = prev | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*SupportResponse, error) { | ||||
| 	var ( | ||||
| 		nodes = []*SupportResponse{} | ||||
| 		_spec = srq.querySpec() | ||||
| 	) | ||||
| 	_spec.ScanValues = func(columns []string) ([]interface{}, error) { | ||||
| 		return (*SupportResponse).scanValues(nil, columns) | ||||
| 	} | ||||
| 	_spec.Assign = func(columns []string, values []interface{}) error { | ||||
| 		node := &SupportResponse{config: srq.config} | ||||
| 		nodes = append(nodes, node) | ||||
| 		return node.assignValues(columns, values) | ||||
| 	} | ||||
| 	for i := range hooks { | ||||
| 		hooks[i](ctx, _spec) | ||||
| 	} | ||||
| 	if err := sqlgraph.QueryNodes(ctx, srq.driver, _spec); err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if len(nodes) == 0 { | ||||
| 		return nodes, nil | ||||
| 	} | ||||
| 	return nodes, nil | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) sqlCount(ctx context.Context) (int, error) { | ||||
| 	_spec := srq.querySpec() | ||||
| 	_spec.Node.Columns = srq.fields | ||||
| 	if len(srq.fields) > 0 { | ||||
| 		_spec.Unique = srq.unique != nil && *srq.unique | ||||
| 	} | ||||
| 	return sqlgraph.CountNodes(ctx, srq.driver, _spec) | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) sqlExist(ctx context.Context) (bool, error) { | ||||
| 	n, err := srq.sqlCount(ctx) | ||||
| 	if err != nil { | ||||
| 		return false, fmt.Errorf("ent: check existence: %w", err) | ||||
| 	} | ||||
| 	return n > 0, nil | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) querySpec() *sqlgraph.QuerySpec { | ||||
| 	_spec := &sqlgraph.QuerySpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   supportresponse.Table, | ||||
| 			Columns: supportresponse.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: supportresponse.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 		From:   srq.sql, | ||||
| 		Unique: true, | ||||
| 	} | ||||
| 	if unique := srq.unique; unique != nil { | ||||
| 		_spec.Unique = *unique | ||||
| 	} | ||||
| 	if fields := srq.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, supportresponse.FieldID) | ||||
| 		for i := range fields { | ||||
| 			if fields[i] != supportresponse.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := srq.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if limit := srq.limit; limit != nil { | ||||
| 		_spec.Limit = *limit | ||||
| 	} | ||||
| 	if offset := srq.offset; offset != nil { | ||||
| 		_spec.Offset = *offset | ||||
| 	} | ||||
| 	if ps := srq.order; len(ps) > 0 { | ||||
| 		_spec.Order = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return _spec | ||||
| } | ||||
|  | ||||
| func (srq *SupportResponseQuery) sqlQuery(ctx context.Context) *sql.Selector { | ||||
| 	builder := sql.Dialect(srq.driver.Dialect()) | ||||
| 	t1 := builder.Table(supportresponse.Table) | ||||
| 	columns := srq.fields | ||||
| 	if len(columns) == 0 { | ||||
| 		columns = supportresponse.Columns | ||||
| 	} | ||||
| 	selector := builder.Select(t1.Columns(columns...)...).From(t1) | ||||
| 	if srq.sql != nil { | ||||
| 		selector = srq.sql | ||||
| 		selector.Select(selector.Columns(columns...)...) | ||||
| 	} | ||||
| 	if srq.unique != nil && *srq.unique { | ||||
| 		selector.Distinct() | ||||
| 	} | ||||
| 	for _, p := range srq.predicates { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	for _, p := range srq.order { | ||||
| 		p(selector) | ||||
| 	} | ||||
| 	if offset := srq.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 := srq.limit; limit != nil { | ||||
| 		selector.Limit(*limit) | ||||
| 	} | ||||
| 	return selector | ||||
| } | ||||
|  | ||||
| // SupportResponseGroupBy is the group-by builder for SupportResponse entities. | ||||
| type SupportResponseGroupBy struct { | ||||
| 	config | ||||
| 	selector | ||||
| 	fields []string | ||||
| 	fns    []AggregateFunc | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql  *sql.Selector | ||||
| 	path func(context.Context) (*sql.Selector, error) | ||||
| } | ||||
|  | ||||
| // Aggregate adds the given aggregation functions to the group-by query. | ||||
| func (srgb *SupportResponseGroupBy) Aggregate(fns ...AggregateFunc) *SupportResponseGroupBy { | ||||
| 	srgb.fns = append(srgb.fns, fns...) | ||||
| 	return srgb | ||||
| } | ||||
|  | ||||
| // Scan applies the group-by query and scans the result into the given value. | ||||
| func (srgb *SupportResponseGroupBy) Scan(ctx context.Context, v interface{}) error { | ||||
| 	query, err := srgb.path(ctx) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	srgb.sql = query | ||||
| 	return srgb.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (srgb *SupportResponseGroupBy) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	for _, f := range srgb.fields { | ||||
| 		if !supportresponse.ValidColumn(f) { | ||||
| 			return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} | ||||
| 		} | ||||
| 	} | ||||
| 	selector := srgb.sqlQuery() | ||||
| 	if err := selector.Err(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := selector.Query() | ||||
| 	if err := srgb.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
|  | ||||
| func (srgb *SupportResponseGroupBy) sqlQuery() *sql.Selector { | ||||
| 	selector := srgb.sql.Select() | ||||
| 	aggregation := make([]string, 0, len(srgb.fns)) | ||||
| 	for _, fn := range srgb.fns { | ||||
| 		aggregation = append(aggregation, fn(selector)) | ||||
| 	} | ||||
| 	// If no columns were selected in a custom aggregation function, the default | ||||
| 	// selection is the fields used for "group-by", and the aggregation functions. | ||||
| 	if len(selector.SelectedColumns()) == 0 { | ||||
| 		columns := make([]string, 0, len(srgb.fields)+len(srgb.fns)) | ||||
| 		for _, f := range srgb.fields { | ||||
| 			columns = append(columns, selector.C(f)) | ||||
| 		} | ||||
| 		columns = append(columns, aggregation...) | ||||
| 		selector.Select(columns...) | ||||
| 	} | ||||
| 	return selector.GroupBy(selector.Columns(srgb.fields...)...) | ||||
| } | ||||
|  | ||||
| // SupportResponseSelect is the builder for selecting fields of SupportResponse entities. | ||||
| type SupportResponseSelect struct { | ||||
| 	*SupportResponseQuery | ||||
| 	selector | ||||
| 	// intermediate query (i.e. traversal path). | ||||
| 	sql *sql.Selector | ||||
| } | ||||
|  | ||||
| // Scan applies the selector query and scans the result into the given value. | ||||
| func (srs *SupportResponseSelect) Scan(ctx context.Context, v interface{}) error { | ||||
| 	if err := srs.prepareQuery(ctx); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	srs.sql = srs.SupportResponseQuery.sqlQuery(ctx) | ||||
| 	return srs.sqlScan(ctx, v) | ||||
| } | ||||
|  | ||||
| func (srs *SupportResponseSelect) sqlScan(ctx context.Context, v interface{}) error { | ||||
| 	rows := &sql.Rows{} | ||||
| 	query, args := srs.sql.Query() | ||||
| 	if err := srs.driver.Query(ctx, query, args, rows); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer rows.Close() | ||||
| 	return sql.ScanSlice(rows, v) | ||||
| } | ||||
							
								
								
									
										428
									
								
								ent/supportresponse_update.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										428
									
								
								ent/supportresponse_update.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,428 @@ | ||||
| // 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/FrankenBotDev/FrankenAPI/ent/predicate" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" | ||||
| ) | ||||
|  | ||||
| // SupportResponseUpdate is the builder for updating SupportResponse entities. | ||||
| type SupportResponseUpdate struct { | ||||
| 	config | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportResponseMutation | ||||
| } | ||||
|  | ||||
| // Where appends a list predicates to the SupportResponseUpdate builder. | ||||
| func (sru *SupportResponseUpdate) Where(ps ...predicate.SupportResponse) *SupportResponseUpdate { | ||||
| 	sru.mutation.Where(ps...) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (sru *SupportResponseUpdate) SetRefid(s string) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetRefid(s) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetWriter sets the "writer" field. | ||||
| func (sru *SupportResponseUpdate) SetWriter(s string) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetWriter(s) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetMessage sets the "message" field. | ||||
| func (sru *SupportResponseUpdate) SetMessage(s string) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetMessage(s) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (sru *SupportResponseUpdate) SetType(s string) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetType(s) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetRtcchannel sets the "rtcchannel" field. | ||||
| func (sru *SupportResponseUpdate) SetRtcchannel(s string) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetRtcchannel(s) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetIsread sets the "isread" field. | ||||
| func (sru *SupportResponseUpdate) SetIsread(b bool) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetIsread(b) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // SetCreated sets the "created" field. | ||||
| func (sru *SupportResponseUpdate) SetCreated(t time.Time) *SupportResponseUpdate { | ||||
| 	sru.mutation.SetCreated(t) | ||||
| 	return sru | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportResponseMutation object of the builder. | ||||
| func (sru *SupportResponseUpdate) Mutation() *SupportResponseMutation { | ||||
| 	return sru.mutation | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the number of nodes affected by the update operation. | ||||
| func (sru *SupportResponseUpdate) Save(ctx context.Context) (int, error) { | ||||
| 	var ( | ||||
| 		err      error | ||||
| 		affected int | ||||
| 	) | ||||
| 	if len(sru.hooks) == 0 { | ||||
| 		affected, err = sru.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportResponseMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sru.mutation = mutation | ||||
| 			affected, err = sru.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return affected, err | ||||
| 		}) | ||||
| 		for i := len(sru.hooks) - 1; i >= 0; i-- { | ||||
| 			if sru.hooks[i] == nil { | ||||
| 				return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sru.hooks[i](mut) | ||||
| 		} | ||||
| 		if _, err := mut.Mutate(ctx, sru.mutation); err != nil { | ||||
| 			return 0, err | ||||
| 		} | ||||
| 	} | ||||
| 	return affected, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (sru *SupportResponseUpdate) SaveX(ctx context.Context) int { | ||||
| 	affected, err := sru.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return affected | ||||
| } | ||||
|  | ||||
| // Exec executes the query. | ||||
| func (sru *SupportResponseUpdate) Exec(ctx context.Context) error { | ||||
| 	_, err := sru.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sru *SupportResponseUpdate) ExecX(ctx context.Context) { | ||||
| 	if err := sru.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (sru *SupportResponseUpdate) sqlSave(ctx context.Context) (n int, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   supportresponse.Table, | ||||
| 			Columns: supportresponse.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: supportresponse.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	if ps := sru.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Writer(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldWriter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Message(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldMessage, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Rtcchannel(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRtcchannel, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Isread(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldIsread, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sru.mutation.Created(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeTime, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldCreated, | ||||
| 		}) | ||||
| 	} | ||||
| 	if n, err = sqlgraph.UpdateNodes(ctx, sru.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{supportresponse.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return n, nil | ||||
| } | ||||
|  | ||||
| // SupportResponseUpdateOne is the builder for updating a single SupportResponse entity. | ||||
| type SupportResponseUpdateOne struct { | ||||
| 	config | ||||
| 	fields   []string | ||||
| 	hooks    []Hook | ||||
| 	mutation *SupportResponseMutation | ||||
| } | ||||
|  | ||||
| // SetRefid sets the "refid" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetRefid(s string) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetRefid(s) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetWriter sets the "writer" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetWriter(s string) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetWriter(s) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetMessage sets the "message" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetMessage(s string) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetMessage(s) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetType sets the "type" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetType(s string) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetType(s) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetRtcchannel sets the "rtcchannel" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetRtcchannel(s string) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetRtcchannel(s) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetIsread sets the "isread" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetIsread(b bool) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetIsread(b) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // SetCreated sets the "created" field. | ||||
| func (sruo *SupportResponseUpdateOne) SetCreated(t time.Time) *SupportResponseUpdateOne { | ||||
| 	sruo.mutation.SetCreated(t) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // Mutation returns the SupportResponseMutation object of the builder. | ||||
| func (sruo *SupportResponseUpdateOne) Mutation() *SupportResponseMutation { | ||||
| 	return sruo.mutation | ||||
| } | ||||
|  | ||||
| // Select allows selecting one or more fields (columns) of the returned entity. | ||||
| // The default is selecting all fields defined in the entity schema. | ||||
| func (sruo *SupportResponseUpdateOne) Select(field string, fields ...string) *SupportResponseUpdateOne { | ||||
| 	sruo.fields = append([]string{field}, fields...) | ||||
| 	return sruo | ||||
| } | ||||
|  | ||||
| // Save executes the query and returns the updated SupportResponse entity. | ||||
| func (sruo *SupportResponseUpdateOne) Save(ctx context.Context) (*SupportResponse, error) { | ||||
| 	var ( | ||||
| 		err  error | ||||
| 		node *SupportResponse | ||||
| 	) | ||||
| 	if len(sruo.hooks) == 0 { | ||||
| 		node, err = sruo.sqlSave(ctx) | ||||
| 	} else { | ||||
| 		var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { | ||||
| 			mutation, ok := m.(*SupportResponseMutation) | ||||
| 			if !ok { | ||||
| 				return nil, fmt.Errorf("unexpected mutation type %T", m) | ||||
| 			} | ||||
| 			sruo.mutation = mutation | ||||
| 			node, err = sruo.sqlSave(ctx) | ||||
| 			mutation.done = true | ||||
| 			return node, err | ||||
| 		}) | ||||
| 		for i := len(sruo.hooks) - 1; i >= 0; i-- { | ||||
| 			if sruo.hooks[i] == nil { | ||||
| 				return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") | ||||
| 			} | ||||
| 			mut = sruo.hooks[i](mut) | ||||
| 		} | ||||
| 		v, err := mut.Mutate(ctx, sruo.mutation) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		nv, ok := v.(*SupportResponse) | ||||
| 		if !ok { | ||||
| 			return nil, fmt.Errorf("unexpected node type %T returned from SupportResponseMutation", v) | ||||
| 		} | ||||
| 		node = nv | ||||
| 	} | ||||
| 	return node, err | ||||
| } | ||||
|  | ||||
| // SaveX is like Save, but panics if an error occurs. | ||||
| func (sruo *SupportResponseUpdateOne) SaveX(ctx context.Context) *SupportResponse { | ||||
| 	node, err := sruo.Save(ctx) | ||||
| 	if err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| 	return node | ||||
| } | ||||
|  | ||||
| // Exec executes the query on the entity. | ||||
| func (sruo *SupportResponseUpdateOne) Exec(ctx context.Context) error { | ||||
| 	_, err := sruo.Save(ctx) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ExecX is like Exec, but panics if an error occurs. | ||||
| func (sruo *SupportResponseUpdateOne) ExecX(ctx context.Context) { | ||||
| 	if err := sruo.Exec(ctx); err != nil { | ||||
| 		panic(err) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (sruo *SupportResponseUpdateOne) sqlSave(ctx context.Context) (_node *SupportResponse, err error) { | ||||
| 	_spec := &sqlgraph.UpdateSpec{ | ||||
| 		Node: &sqlgraph.NodeSpec{ | ||||
| 			Table:   supportresponse.Table, | ||||
| 			Columns: supportresponse.Columns, | ||||
| 			ID: &sqlgraph.FieldSpec{ | ||||
| 				Type:   field.TypeInt, | ||||
| 				Column: supportresponse.FieldID, | ||||
| 			}, | ||||
| 		}, | ||||
| 	} | ||||
| 	id, ok := sruo.mutation.ID() | ||||
| 	if !ok { | ||||
| 		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "SupportResponse.id" for update`)} | ||||
| 	} | ||||
| 	_spec.Node.ID.Value = id | ||||
| 	if fields := sruo.fields; len(fields) > 0 { | ||||
| 		_spec.Node.Columns = make([]string, 0, len(fields)) | ||||
| 		_spec.Node.Columns = append(_spec.Node.Columns, supportresponse.FieldID) | ||||
| 		for _, f := range fields { | ||||
| 			if !supportresponse.ValidColumn(f) { | ||||
| 				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} | ||||
| 			} | ||||
| 			if f != supportresponse.FieldID { | ||||
| 				_spec.Node.Columns = append(_spec.Node.Columns, f) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if ps := sruo.mutation.predicates; len(ps) > 0 { | ||||
| 		_spec.Predicate = func(selector *sql.Selector) { | ||||
| 			for i := range ps { | ||||
| 				ps[i](selector) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Refid(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRefid, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Writer(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldWriter, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Message(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldMessage, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.GetType(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldType, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Rtcchannel(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeString, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldRtcchannel, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Isread(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeBool, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldIsread, | ||||
| 		}) | ||||
| 	} | ||||
| 	if value, ok := sruo.mutation.Created(); ok { | ||||
| 		_spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ | ||||
| 			Type:   field.TypeTime, | ||||
| 			Value:  value, | ||||
| 			Column: supportresponse.FieldCreated, | ||||
| 		}) | ||||
| 	} | ||||
| 	_node = &SupportResponse{config: sruo.config} | ||||
| 	_spec.Assign = _node.assignValues | ||||
| 	_spec.ScanValues = _node.scanValues | ||||
| 	if err = sqlgraph.UpdateNode(ctx, sruo.driver, _spec); err != nil { | ||||
| 		if _, ok := err.(*sqlgraph.NotFoundError); ok { | ||||
| 			err = &NotFoundError{supportresponse.Label} | ||||
| 		} else if sqlgraph.IsConstraintError(err) { | ||||
| 			err = &ConstraintError{msg: err.Error(), wrap: err} | ||||
| 		} | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return _node, nil | ||||
| } | ||||
							
								
								
									
										243
									
								
								ent/tx.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								ent/tx.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,243 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"sync" | ||||
|  | ||||
| 	"entgo.io/ent/dialect" | ||||
| ) | ||||
|  | ||||
| // Tx is a transactional client that is created by calling Client.Tx(). | ||||
| type Tx struct { | ||||
| 	config | ||||
| 	// Actions is the client for interacting with the Actions builders. | ||||
| 	Actions *ActionsClient | ||||
| 	// Authorizables is the client for interacting with the Authorizables builders. | ||||
| 	Authorizables *AuthorizablesClient | ||||
| 	// Blacklist is the client for interacting with the Blacklist builders. | ||||
| 	Blacklist *BlacklistClient | ||||
| 	// Logging is the client for interacting with the Logging builders. | ||||
| 	Logging *LoggingClient | ||||
| 	// Punishments is the client for interacting with the Punishments builders. | ||||
| 	Punishments *PunishmentsClient | ||||
| 	// Servers is the client for interacting with the Servers builders. | ||||
| 	Servers *ServersClient | ||||
| 	// Settings is the client for interacting with the Settings builders. | ||||
| 	Settings *SettingsClient | ||||
| 	// Socialmedia is the client for interacting with the Socialmedia builders. | ||||
| 	Socialmedia *SocialmediaClient | ||||
| 	// Support is the client for interacting with the Support builders. | ||||
| 	Support *SupportClient | ||||
| 	// SupportResponse is the client for interacting with the SupportResponse builders. | ||||
| 	SupportResponse *SupportResponseClient | ||||
| 	// User is the client for interacting with the User builders. | ||||
| 	User *UserClient | ||||
| 	// Warns is the client for interacting with the Warns builders. | ||||
| 	Warns *WarnsClient | ||||
|  | ||||
| 	// lazily loaded. | ||||
| 	client     *Client | ||||
| 	clientOnce sync.Once | ||||
|  | ||||
| 	// completion callbacks. | ||||
| 	mu         sync.Mutex | ||||
| 	onCommit   []CommitHook | ||||
| 	onRollback []RollbackHook | ||||
|  | ||||
| 	// ctx lives for the life of the transaction. It is | ||||
| 	// the same context used by the underlying connection. | ||||
| 	ctx context.Context | ||||
| } | ||||
|  | ||||
| type ( | ||||
| 	// Committer is the interface that wraps the Commit method. | ||||
| 	Committer interface { | ||||
| 		Commit(context.Context, *Tx) error | ||||
| 	} | ||||
|  | ||||
| 	// The CommitFunc type is an adapter to allow the use of ordinary | ||||
| 	// function as a Committer. If f is a function with the appropriate | ||||
| 	// signature, CommitFunc(f) is a Committer that calls f. | ||||
| 	CommitFunc func(context.Context, *Tx) error | ||||
|  | ||||
| 	// CommitHook defines the "commit middleware". A function that gets a Committer | ||||
| 	// and returns a Committer. For example: | ||||
| 	// | ||||
| 	//	hook := func(next ent.Committer) ent.Committer { | ||||
| 	//		return ent.CommitFunc(func(ctx context.Context, tx *ent.Tx) error { | ||||
| 	//			// Do some stuff before. | ||||
| 	//			if err := next.Commit(ctx, tx); err != nil { | ||||
| 	//				return err | ||||
| 	//			} | ||||
| 	//			// Do some stuff after. | ||||
| 	//			return nil | ||||
| 	//		}) | ||||
| 	//	} | ||||
| 	// | ||||
| 	CommitHook func(Committer) Committer | ||||
| ) | ||||
|  | ||||
| // Commit calls f(ctx, m). | ||||
| func (f CommitFunc) Commit(ctx context.Context, tx *Tx) error { | ||||
| 	return f(ctx, tx) | ||||
| } | ||||
|  | ||||
| // Commit commits the transaction. | ||||
| func (tx *Tx) Commit() error { | ||||
| 	txDriver := tx.config.driver.(*txDriver) | ||||
| 	var fn Committer = CommitFunc(func(context.Context, *Tx) error { | ||||
| 		return txDriver.tx.Commit() | ||||
| 	}) | ||||
| 	tx.mu.Lock() | ||||
| 	hooks := append([]CommitHook(nil), tx.onCommit...) | ||||
| 	tx.mu.Unlock() | ||||
| 	for i := len(hooks) - 1; i >= 0; i-- { | ||||
| 		fn = hooks[i](fn) | ||||
| 	} | ||||
| 	return fn.Commit(tx.ctx, tx) | ||||
| } | ||||
|  | ||||
| // OnCommit adds a hook to call on commit. | ||||
| func (tx *Tx) OnCommit(f CommitHook) { | ||||
| 	tx.mu.Lock() | ||||
| 	defer tx.mu.Unlock() | ||||
| 	tx.onCommit = append(tx.onCommit, f) | ||||
| } | ||||
|  | ||||
| type ( | ||||
| 	// Rollbacker is the interface that wraps the Rollback method. | ||||
| 	Rollbacker interface { | ||||
| 		Rollback(context.Context, *Tx) error | ||||
| 	} | ||||
|  | ||||
| 	// The RollbackFunc type is an adapter to allow the use of ordinary | ||||
| 	// function as a Rollbacker. If f is a function with the appropriate | ||||
| 	// signature, RollbackFunc(f) is a Rollbacker that calls f. | ||||
| 	RollbackFunc func(context.Context, *Tx) error | ||||
|  | ||||
| 	// RollbackHook defines the "rollback middleware". A function that gets a Rollbacker | ||||
| 	// and returns a Rollbacker. For example: | ||||
| 	// | ||||
| 	//	hook := func(next ent.Rollbacker) ent.Rollbacker { | ||||
| 	//		return ent.RollbackFunc(func(ctx context.Context, tx *ent.Tx) error { | ||||
| 	//			// Do some stuff before. | ||||
| 	//			if err := next.Rollback(ctx, tx); err != nil { | ||||
| 	//				return err | ||||
| 	//			} | ||||
| 	//			// Do some stuff after. | ||||
| 	//			return nil | ||||
| 	//		}) | ||||
| 	//	} | ||||
| 	// | ||||
| 	RollbackHook func(Rollbacker) Rollbacker | ||||
| ) | ||||
|  | ||||
| // Rollback calls f(ctx, m). | ||||
| func (f RollbackFunc) Rollback(ctx context.Context, tx *Tx) error { | ||||
| 	return f(ctx, tx) | ||||
| } | ||||
|  | ||||
| // Rollback rollbacks the transaction. | ||||
| func (tx *Tx) Rollback() error { | ||||
| 	txDriver := tx.config.driver.(*txDriver) | ||||
| 	var fn Rollbacker = RollbackFunc(func(context.Context, *Tx) error { | ||||
| 		return txDriver.tx.Rollback() | ||||
| 	}) | ||||
| 	tx.mu.Lock() | ||||
| 	hooks := append([]RollbackHook(nil), tx.onRollback...) | ||||
| 	tx.mu.Unlock() | ||||
| 	for i := len(hooks) - 1; i >= 0; i-- { | ||||
| 		fn = hooks[i](fn) | ||||
| 	} | ||||
| 	return fn.Rollback(tx.ctx, tx) | ||||
| } | ||||
|  | ||||
| // OnRollback adds a hook to call on rollback. | ||||
| func (tx *Tx) OnRollback(f RollbackHook) { | ||||
| 	tx.mu.Lock() | ||||
| 	defer tx.mu.Unlock() | ||||
| 	tx.onRollback = append(tx.onRollback, f) | ||||
| } | ||||
|  | ||||
| // Client returns a Client that binds to current transaction. | ||||
| func (tx *Tx) Client() *Client { | ||||
| 	tx.clientOnce.Do(func() { | ||||
| 		tx.client = &Client{config: tx.config} | ||||
| 		tx.client.init() | ||||
| 	}) | ||||
| 	return tx.client | ||||
| } | ||||
|  | ||||
| func (tx *Tx) init() { | ||||
| 	tx.Actions = NewActionsClient(tx.config) | ||||
| 	tx.Authorizables = NewAuthorizablesClient(tx.config) | ||||
| 	tx.Blacklist = NewBlacklistClient(tx.config) | ||||
| 	tx.Logging = NewLoggingClient(tx.config) | ||||
| 	tx.Punishments = NewPunishmentsClient(tx.config) | ||||
| 	tx.Servers = NewServersClient(tx.config) | ||||
| 	tx.Settings = NewSettingsClient(tx.config) | ||||
| 	tx.Socialmedia = NewSocialmediaClient(tx.config) | ||||
| 	tx.Support = NewSupportClient(tx.config) | ||||
| 	tx.SupportResponse = NewSupportResponseClient(tx.config) | ||||
| 	tx.User = NewUserClient(tx.config) | ||||
| 	tx.Warns = NewWarnsClient(tx.config) | ||||
| } | ||||
|  | ||||
| // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation. | ||||
| // The idea is to support transactions without adding any extra code to the builders. | ||||
| // When a builder calls to driver.Tx(), it gets the same dialect.Tx instance. | ||||
| // Commit and Rollback are nop for the internal builders and the user must call one | ||||
| // of them in order to commit or rollback the transaction. | ||||
| // | ||||
| // If a closed transaction is embedded in one of the generated entities, and the entity | ||||
| // applies a query, for example: Actions.QueryXXX(), the query will be executed | ||||
| // through the driver which created this transaction. | ||||
| // | ||||
| // Note that txDriver is not goroutine safe. | ||||
| type txDriver struct { | ||||
| 	// the driver we started the transaction from. | ||||
| 	drv dialect.Driver | ||||
| 	// tx is the underlying transaction. | ||||
| 	tx dialect.Tx | ||||
| } | ||||
|  | ||||
| // newTx creates a new transactional driver. | ||||
| func newTx(ctx context.Context, drv dialect.Driver) (*txDriver, error) { | ||||
| 	tx, err := drv.Tx(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &txDriver{tx: tx, drv: drv}, nil | ||||
| } | ||||
|  | ||||
| // Tx returns the transaction wrapper (txDriver) to avoid Commit or Rollback calls | ||||
| // from the internal builders. Should be called only by the internal builders. | ||||
| func (tx *txDriver) Tx(context.Context) (dialect.Tx, error) { return tx, nil } | ||||
|  | ||||
| // Dialect returns the dialect of the driver we started the transaction from. | ||||
| func (tx *txDriver) Dialect() string { return tx.drv.Dialect() } | ||||
|  | ||||
| // Close is a nop close. | ||||
| func (*txDriver) Close() error { return nil } | ||||
|  | ||||
| // Commit is a nop commit for the internal builders. | ||||
| // User must call `Tx.Commit` in order to commit the transaction. | ||||
| func (*txDriver) Commit() error { return nil } | ||||
|  | ||||
| // Rollback is a nop rollback for the internal builders. | ||||
| // User must call `Tx.Rollback` in order to rollback the transaction. | ||||
| func (*txDriver) Rollback() error { return nil } | ||||
|  | ||||
| // Exec calls tx.Exec. | ||||
| func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error { | ||||
| 	return tx.tx.Exec(ctx, query, args, v) | ||||
| } | ||||
|  | ||||
| // Query calls tx.Query. | ||||
| func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error { | ||||
| 	return tx.tx.Query(ctx, query, args, v) | ||||
| } | ||||
|  | ||||
| var _ dialect.Driver = (*txDriver)(nil) | ||||
							
								
								
									
										168
									
								
								ent/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										168
									
								
								ent/user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,168 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package ent | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"entgo.io/ent/dialect/sql" | ||||
| 	"github.com/FrankenBotDev/FrankenAPI/ent/user" | ||||
| ) | ||||
|  | ||||
| // User is the model entity for the User schema. | ||||
| type User struct { | ||||
| 	config `json:"-"` | ||||
| 	// ID of the ent. | ||||
| 	ID int `json:"id,omitempty"` | ||||
| 	// Serverid holds the value of the "serverid" field. | ||||
| 	Serverid string `json:"serverid,omitempty"` | ||||
| 	// Userid holds the value of the "userid" field. | ||||
| 	Userid string `json:"userid,omitempty"` | ||||
| 	// Username holds the value of the "username" field. | ||||
| 	Username string `json:"username,omitempty"` | ||||
| 	// Xp holds the value of the "xp" field. | ||||
| 	Xp int `json:"xp,omitempty"` | ||||
| 	// Level holds the value of the "level" field. | ||||
| 	Level int `json:"level,omitempty"` | ||||
| 	// Msgs holds the value of the "msgs" field. | ||||
| 	Msgs int `json:"msgs,omitempty"` | ||||
| 	// Created holds the value of the "created" field. | ||||
| 	Created time.Time `json:"created,omitempty"` | ||||
| } | ||||
|  | ||||
| // scanValues returns the types for scanning values from sql.Rows. | ||||
| func (*User) scanValues(columns []string) ([]interface{}, error) { | ||||
| 	values := make([]interface{}, len(columns)) | ||||
| 	for i := range columns { | ||||
| 		switch columns[i] { | ||||
| 		case user.FieldID, user.FieldXp, user.FieldLevel, user.FieldMsgs: | ||||
| 			values[i] = new(sql.NullInt64) | ||||
| 		case user.FieldServerid, user.FieldUserid, user.FieldUsername: | ||||
| 			values[i] = new(sql.NullString) | ||||
| 		case user.FieldCreated: | ||||
| 			values[i] = new(sql.NullTime) | ||||
| 		default: | ||||
| 			return nil, fmt.Errorf("unexpected column %q for type User", columns[i]) | ||||
| 		} | ||||
| 	} | ||||
| 	return values, nil | ||||
| } | ||||
|  | ||||
| // assignValues assigns the values that were returned from sql.Rows (after scanning) | ||||
| // to the User fields. | ||||
| func (u *User) assignValues(columns []string, values []interface{}) 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 user.FieldID: | ||||
| 			value, ok := values[i].(*sql.NullInt64) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field id", value) | ||||
| 			} | ||||
| 			u.ID = int(value.Int64) | ||||
| 		case user.FieldServerid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field serverid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Serverid = value.String | ||||
| 			} | ||||
| 		case user.FieldUserid: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field userid", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Userid = value.String | ||||
| 			} | ||||
| 		case user.FieldUsername: | ||||
| 			if value, ok := values[i].(*sql.NullString); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field username", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Username = value.String | ||||
| 			} | ||||
| 		case user.FieldXp: | ||||
| 			if value, ok := values[i].(*sql.NullInt64); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field xp", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Xp = int(value.Int64) | ||||
| 			} | ||||
| 		case user.FieldLevel: | ||||
| 			if value, ok := values[i].(*sql.NullInt64); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field level", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Level = int(value.Int64) | ||||
| 			} | ||||
| 		case user.FieldMsgs: | ||||
| 			if value, ok := values[i].(*sql.NullInt64); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field msgs", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Msgs = int(value.Int64) | ||||
| 			} | ||||
| 		case user.FieldCreated: | ||||
| 			if value, ok := values[i].(*sql.NullTime); !ok { | ||||
| 				return fmt.Errorf("unexpected type %T for field created", values[i]) | ||||
| 			} else if value.Valid { | ||||
| 				u.Created = value.Time | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Update returns a builder for updating this User. | ||||
| // Note that you need to call User.Unwrap() before calling this method if this User | ||||
| // was returned from a transaction, and the transaction was committed or rolled back. | ||||
| func (u *User) Update() *UserUpdateOne { | ||||
| 	return (&UserClient{config: u.config}).UpdateOne(u) | ||||
| } | ||||
|  | ||||
| // Unwrap unwraps the User 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 (u *User) Unwrap() *User { | ||||
| 	_tx, ok := u.config.driver.(*txDriver) | ||||
| 	if !ok { | ||||
| 		panic("ent: User is not a transactional entity") | ||||
| 	} | ||||
| 	u.config.driver = _tx.drv | ||||
| 	return u | ||||
| } | ||||
|  | ||||
| // String implements the fmt.Stringer. | ||||
| func (u *User) String() string { | ||||
| 	var builder strings.Builder | ||||
| 	builder.WriteString("User(") | ||||
| 	builder.WriteString(fmt.Sprintf("id=%v, ", u.ID)) | ||||
| 	builder.WriteString("serverid=") | ||||
| 	builder.WriteString(u.Serverid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("userid=") | ||||
| 	builder.WriteString(u.Userid) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("username=") | ||||
| 	builder.WriteString(u.Username) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("xp=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", u.Xp)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("level=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", u.Level)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("msgs=") | ||||
| 	builder.WriteString(fmt.Sprintf("%v", u.Msgs)) | ||||
| 	builder.WriteString(", ") | ||||
| 	builder.WriteString("created=") | ||||
| 	builder.WriteString(u.Created.Format(time.ANSIC)) | ||||
| 	builder.WriteByte(')') | ||||
| 	return builder.String() | ||||
| } | ||||
|  | ||||
| // Users is a parsable slice of User. | ||||
| type Users []*User | ||||
|  | ||||
| func (u Users) config(cfg config) { | ||||
| 	for _i := range u { | ||||
| 		u[_i].config = cfg | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										57
									
								
								ent/user/user.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								ent/user/user.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,57 @@ | ||||
| // Code generated by ent, DO NOT EDIT. | ||||
|  | ||||
| package user | ||||
|  | ||||
| const ( | ||||
| 	// Label holds the string label denoting the user type in the database. | ||||
| 	Label = "user" | ||||
| 	// FieldID holds the string denoting the id field in the database. | ||||
| 	FieldID = "id" | ||||
| 	// FieldServerid holds the string denoting the serverid field in the database. | ||||
| 	FieldServerid = "serverid" | ||||
| 	// FieldUserid holds the string denoting the userid field in the database. | ||||
| 	FieldUserid = "userid" | ||||
| 	// FieldUsername holds the string denoting the username field in the database. | ||||
| 	FieldUsername = "username" | ||||
| 	// FieldXp holds the string denoting the xp field in the database. | ||||
| 	FieldXp = "xp" | ||||
| 	// FieldLevel holds the string denoting the level field in the database. | ||||
| 	FieldLevel = "level" | ||||
| 	// FieldMsgs holds the string denoting the msgs field in the database. | ||||
| 	FieldMsgs = "msgs" | ||||
| 	// FieldCreated holds the string denoting the created field in the database. | ||||
| 	FieldCreated = "created" | ||||
| 	// Table holds the table name of the user in the database. | ||||
| 	Table = "users" | ||||
| ) | ||||
|  | ||||
| // Columns holds all SQL columns for user fields. | ||||
| var Columns = []string{ | ||||
| 	FieldID, | ||||
| 	FieldServerid, | ||||
| 	FieldUserid, | ||||
| 	FieldUsername, | ||||
| 	FieldXp, | ||||
| 	FieldLevel, | ||||
| 	FieldMsgs, | ||||
| 	FieldCreated, | ||||
| } | ||||
|  | ||||
| // 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 ( | ||||
| 	// DefaultXp holds the default value on creation for the "xp" field. | ||||
| 	DefaultXp int | ||||
| 	// DefaultLevel holds the default value on creation for the "level" field. | ||||
| 	DefaultLevel int | ||||
| 	// DefaultMsgs holds the default value on creation for the "msgs" field. | ||||
| 	DefaultMsgs int | ||||
| ) | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user