commit 447b2fb51df3fa2b7f18190d088055d364f744e4 Author: maurice fletgen Date: Thu Sep 8 09:18:04 2022 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/apiDoc.txt b/apiDoc.txt new file mode 100644 index 0000000..68f15e5 --- /dev/null +++ b/apiDoc.txt @@ -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 +} diff --git a/ent/actions.go b/ent/actions.go new file mode 100644 index 0000000..f08a4d8 --- /dev/null +++ b/ent/actions.go @@ -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 + } +} diff --git a/ent/actions/actions.go b/ent/actions/actions.go new file mode 100644 index 0000000..85d232a --- /dev/null +++ b/ent/actions/actions.go @@ -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 +) diff --git a/ent/actions/where.go b/ent/actions/where.go new file mode 100644 index 0000000..49da8a0 --- /dev/null +++ b/ent/actions/where.go @@ -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()) + }) +} diff --git a/ent/actions_create.go b/ent/actions_create.go new file mode 100644 index 0000000..70f021d --- /dev/null +++ b/ent/actions_create.go @@ -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) + } +} diff --git a/ent/actions_delete.go b/ent/actions_delete.go new file mode 100644 index 0000000..816c368 --- /dev/null +++ b/ent/actions_delete.go @@ -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) +} diff --git a/ent/actions_query.go b/ent/actions_query.go new file mode 100644 index 0000000..0e1c6fa --- /dev/null +++ b/ent/actions_query.go @@ -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) +} diff --git a/ent/actions_update.go b/ent/actions_update.go new file mode 100644 index 0000000..a89ee82 --- /dev/null +++ b/ent/actions_update.go @@ -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 +} diff --git a/ent/authorizables.go b/ent/authorizables.go new file mode 100644 index 0000000..ff0a2a7 --- /dev/null +++ b/ent/authorizables.go @@ -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 + } +} diff --git a/ent/authorizables/authorizables.go b/ent/authorizables/authorizables.go new file mode 100644 index 0000000..be4635a --- /dev/null +++ b/ent/authorizables/authorizables.go @@ -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 +} diff --git a/ent/authorizables/where.go b/ent/authorizables/where.go new file mode 100644 index 0000000..2687fe7 --- /dev/null +++ b/ent/authorizables/where.go @@ -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()) + }) +} diff --git a/ent/authorizables_create.go b/ent/authorizables_create.go new file mode 100644 index 0000000..afbb738 --- /dev/null +++ b/ent/authorizables_create.go @@ -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) + } +} diff --git a/ent/authorizables_delete.go b/ent/authorizables_delete.go new file mode 100644 index 0000000..06bd91f --- /dev/null +++ b/ent/authorizables_delete.go @@ -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) +} diff --git a/ent/authorizables_query.go b/ent/authorizables_query.go new file mode 100644 index 0000000..00c40a2 --- /dev/null +++ b/ent/authorizables_query.go @@ -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) +} diff --git a/ent/authorizables_update.go b/ent/authorizables_update.go new file mode 100644 index 0000000..b0e1660 --- /dev/null +++ b/ent/authorizables_update.go @@ -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 +} diff --git a/ent/blacklist.go b/ent/blacklist.go new file mode 100644 index 0000000..2d66b12 --- /dev/null +++ b/ent/blacklist.go @@ -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 + } +} diff --git a/ent/blacklist/blacklist.go b/ent/blacklist/blacklist.go new file mode 100644 index 0000000..2bc1b0e --- /dev/null +++ b/ent/blacklist/blacklist.go @@ -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 +} diff --git a/ent/blacklist/where.go b/ent/blacklist/where.go new file mode 100644 index 0000000..fa6d7e3 --- /dev/null +++ b/ent/blacklist/where.go @@ -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()) + }) +} diff --git a/ent/blacklist_create.go b/ent/blacklist_create.go new file mode 100644 index 0000000..ce1ddfe --- /dev/null +++ b/ent/blacklist_create.go @@ -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) + } +} diff --git a/ent/blacklist_delete.go b/ent/blacklist_delete.go new file mode 100644 index 0000000..aa8553f --- /dev/null +++ b/ent/blacklist_delete.go @@ -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) +} diff --git a/ent/blacklist_query.go b/ent/blacklist_query.go new file mode 100644 index 0000000..7055f37 --- /dev/null +++ b/ent/blacklist_query.go @@ -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) +} diff --git a/ent/blacklist_update.go b/ent/blacklist_update.go new file mode 100644 index 0000000..2bbfc9b --- /dev/null +++ b/ent/blacklist_update.go @@ -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 +} diff --git a/ent/client.go b/ent/client.go new file mode 100644 index 0000000..2e4c5b1 --- /dev/null +++ b/ent/client.go @@ -0,0 +1,1280 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "fmt" + "log" + + "github.com/FrankenBotDev/FrankenAPI/ent/migrate" + + "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" + + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" +) + +// Client is the client that holds all ent builders. +type Client struct { + config + // Schema is the client for creating, migrating and dropping schema. + Schema *migrate.Schema + // 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 +} + +// NewClient creates a new client configured with the given options. +func NewClient(opts ...Option) *Client { + cfg := config{log: log.Println, hooks: &hooks{}} + cfg.options(opts...) + client := &Client{config: cfg} + client.init() + return client +} + +func (c *Client) init() { + c.Schema = migrate.NewSchema(c.driver) + c.Actions = NewActionsClient(c.config) + c.Authorizables = NewAuthorizablesClient(c.config) + c.Blacklist = NewBlacklistClient(c.config) + c.Logging = NewLoggingClient(c.config) + c.Punishments = NewPunishmentsClient(c.config) + c.Servers = NewServersClient(c.config) + c.Settings = NewSettingsClient(c.config) + c.Socialmedia = NewSocialmediaClient(c.config) + c.Support = NewSupportClient(c.config) + c.SupportResponse = NewSupportResponseClient(c.config) + c.User = NewUserClient(c.config) + c.Warns = NewWarnsClient(c.config) +} + +// Open opens a database/sql.DB specified by the driver name and +// the data source name, and returns a new client attached to it. +// Optional parameters can be added for configuring the client. +func Open(driverName, dataSourceName string, options ...Option) (*Client, error) { + switch driverName { + case dialect.MySQL, dialect.Postgres, dialect.SQLite: + drv, err := sql.Open(driverName, dataSourceName) + if err != nil { + return nil, err + } + return NewClient(append(options, Driver(drv))...), nil + default: + return nil, fmt.Errorf("unsupported driver: %q", driverName) + } +} + +// Tx returns a new transactional client. The provided context +// is used until the transaction is committed or rolled back. +func (c *Client) Tx(ctx context.Context) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := newTx(ctx, c.driver) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = tx + return &Tx{ + ctx: ctx, + config: cfg, + Actions: NewActionsClient(cfg), + Authorizables: NewAuthorizablesClient(cfg), + Blacklist: NewBlacklistClient(cfg), + Logging: NewLoggingClient(cfg), + Punishments: NewPunishmentsClient(cfg), + Servers: NewServersClient(cfg), + Settings: NewSettingsClient(cfg), + Socialmedia: NewSocialmediaClient(cfg), + Support: NewSupportClient(cfg), + SupportResponse: NewSupportResponseClient(cfg), + User: NewUserClient(cfg), + Warns: NewWarnsClient(cfg), + }, nil +} + +// BeginTx returns a transactional client with specified options. +func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { + if _, ok := c.driver.(*txDriver); ok { + return nil, fmt.Errorf("ent: cannot start a transaction within a transaction") + } + tx, err := c.driver.(interface { + BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error) + }).BeginTx(ctx, opts) + if err != nil { + return nil, fmt.Errorf("ent: starting a transaction: %w", err) + } + cfg := c.config + cfg.driver = &txDriver{tx: tx, drv: c.driver} + return &Tx{ + ctx: ctx, + config: cfg, + Actions: NewActionsClient(cfg), + Authorizables: NewAuthorizablesClient(cfg), + Blacklist: NewBlacklistClient(cfg), + Logging: NewLoggingClient(cfg), + Punishments: NewPunishmentsClient(cfg), + Servers: NewServersClient(cfg), + Settings: NewSettingsClient(cfg), + Socialmedia: NewSocialmediaClient(cfg), + Support: NewSupportClient(cfg), + SupportResponse: NewSupportResponseClient(cfg), + User: NewUserClient(cfg), + Warns: NewWarnsClient(cfg), + }, nil +} + +// Debug returns a new debug-client. It's used to get verbose logging on specific operations. +// +// client.Debug(). +// Actions. +// Query(). +// Count(ctx) +// +func (c *Client) Debug() *Client { + if c.debug { + return c + } + cfg := c.config + cfg.driver = dialect.Debug(c.driver, c.log) + client := &Client{config: cfg} + client.init() + return client +} + +// Close closes the database connection and prevents new queries from starting. +func (c *Client) Close() error { + return c.driver.Close() +} + +// Use adds the mutation hooks to all the entity clients. +// In order to add hooks to a specific client, call: `client.Node.Use(...)`. +func (c *Client) Use(hooks ...Hook) { + c.Actions.Use(hooks...) + c.Authorizables.Use(hooks...) + c.Blacklist.Use(hooks...) + c.Logging.Use(hooks...) + c.Punishments.Use(hooks...) + c.Servers.Use(hooks...) + c.Settings.Use(hooks...) + c.Socialmedia.Use(hooks...) + c.Support.Use(hooks...) + c.SupportResponse.Use(hooks...) + c.User.Use(hooks...) + c.Warns.Use(hooks...) +} + +// ActionsClient is a client for the Actions schema. +type ActionsClient struct { + config +} + +// NewActionsClient returns a client for the Actions from the given config. +func NewActionsClient(c config) *ActionsClient { + return &ActionsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `actions.Hooks(f(g(h())))`. +func (c *ActionsClient) Use(hooks ...Hook) { + c.hooks.Actions = append(c.hooks.Actions, hooks...) +} + +// Create returns a builder for creating a Actions entity. +func (c *ActionsClient) Create() *ActionsCreate { + mutation := newActionsMutation(c.config, OpCreate) + return &ActionsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Actions entities. +func (c *ActionsClient) CreateBulk(builders ...*ActionsCreate) *ActionsCreateBulk { + return &ActionsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Actions. +func (c *ActionsClient) Update() *ActionsUpdate { + mutation := newActionsMutation(c.config, OpUpdate) + return &ActionsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ActionsClient) UpdateOne(a *Actions) *ActionsUpdateOne { + mutation := newActionsMutation(c.config, OpUpdateOne, withActions(a)) + return &ActionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ActionsClient) UpdateOneID(id int) *ActionsUpdateOne { + mutation := newActionsMutation(c.config, OpUpdateOne, withActionsID(id)) + return &ActionsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Actions. +func (c *ActionsClient) Delete() *ActionsDelete { + mutation := newActionsMutation(c.config, OpDelete) + return &ActionsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ActionsClient) DeleteOne(a *Actions) *ActionsDeleteOne { + return c.DeleteOneID(a.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *ActionsClient) DeleteOneID(id int) *ActionsDeleteOne { + builder := c.Delete().Where(actions.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ActionsDeleteOne{builder} +} + +// Query returns a query builder for Actions. +func (c *ActionsClient) Query() *ActionsQuery { + return &ActionsQuery{ + config: c.config, + } +} + +// Get returns a Actions entity by its id. +func (c *ActionsClient) Get(ctx context.Context, id int) (*Actions, error) { + return c.Query().Where(actions.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ActionsClient) GetX(ctx context.Context, id int) *Actions { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *ActionsClient) Hooks() []Hook { + return c.hooks.Actions +} + +// AuthorizablesClient is a client for the Authorizables schema. +type AuthorizablesClient struct { + config +} + +// NewAuthorizablesClient returns a client for the Authorizables from the given config. +func NewAuthorizablesClient(c config) *AuthorizablesClient { + return &AuthorizablesClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `authorizables.Hooks(f(g(h())))`. +func (c *AuthorizablesClient) Use(hooks ...Hook) { + c.hooks.Authorizables = append(c.hooks.Authorizables, hooks...) +} + +// Create returns a builder for creating a Authorizables entity. +func (c *AuthorizablesClient) Create() *AuthorizablesCreate { + mutation := newAuthorizablesMutation(c.config, OpCreate) + return &AuthorizablesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Authorizables entities. +func (c *AuthorizablesClient) CreateBulk(builders ...*AuthorizablesCreate) *AuthorizablesCreateBulk { + return &AuthorizablesCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Authorizables. +func (c *AuthorizablesClient) Update() *AuthorizablesUpdate { + mutation := newAuthorizablesMutation(c.config, OpUpdate) + return &AuthorizablesUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *AuthorizablesClient) UpdateOne(a *Authorizables) *AuthorizablesUpdateOne { + mutation := newAuthorizablesMutation(c.config, OpUpdateOne, withAuthorizables(a)) + return &AuthorizablesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *AuthorizablesClient) UpdateOneID(id int) *AuthorizablesUpdateOne { + mutation := newAuthorizablesMutation(c.config, OpUpdateOne, withAuthorizablesID(id)) + return &AuthorizablesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Authorizables. +func (c *AuthorizablesClient) Delete() *AuthorizablesDelete { + mutation := newAuthorizablesMutation(c.config, OpDelete) + return &AuthorizablesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *AuthorizablesClient) DeleteOne(a *Authorizables) *AuthorizablesDeleteOne { + return c.DeleteOneID(a.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *AuthorizablesClient) DeleteOneID(id int) *AuthorizablesDeleteOne { + builder := c.Delete().Where(authorizables.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &AuthorizablesDeleteOne{builder} +} + +// Query returns a query builder for Authorizables. +func (c *AuthorizablesClient) Query() *AuthorizablesQuery { + return &AuthorizablesQuery{ + config: c.config, + } +} + +// Get returns a Authorizables entity by its id. +func (c *AuthorizablesClient) Get(ctx context.Context, id int) (*Authorizables, error) { + return c.Query().Where(authorizables.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *AuthorizablesClient) GetX(ctx context.Context, id int) *Authorizables { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *AuthorizablesClient) Hooks() []Hook { + return c.hooks.Authorizables +} + +// BlacklistClient is a client for the Blacklist schema. +type BlacklistClient struct { + config +} + +// NewBlacklistClient returns a client for the Blacklist from the given config. +func NewBlacklistClient(c config) *BlacklistClient { + return &BlacklistClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `blacklist.Hooks(f(g(h())))`. +func (c *BlacklistClient) Use(hooks ...Hook) { + c.hooks.Blacklist = append(c.hooks.Blacklist, hooks...) +} + +// Create returns a builder for creating a Blacklist entity. +func (c *BlacklistClient) Create() *BlacklistCreate { + mutation := newBlacklistMutation(c.config, OpCreate) + return &BlacklistCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Blacklist entities. +func (c *BlacklistClient) CreateBulk(builders ...*BlacklistCreate) *BlacklistCreateBulk { + return &BlacklistCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Blacklist. +func (c *BlacklistClient) Update() *BlacklistUpdate { + mutation := newBlacklistMutation(c.config, OpUpdate) + return &BlacklistUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *BlacklistClient) UpdateOne(b *Blacklist) *BlacklistUpdateOne { + mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklist(b)) + return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *BlacklistClient) UpdateOneID(id int) *BlacklistUpdateOne { + mutation := newBlacklistMutation(c.config, OpUpdateOne, withBlacklistID(id)) + return &BlacklistUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Blacklist. +func (c *BlacklistClient) Delete() *BlacklistDelete { + mutation := newBlacklistMutation(c.config, OpDelete) + return &BlacklistDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *BlacklistClient) DeleteOne(b *Blacklist) *BlacklistDeleteOne { + return c.DeleteOneID(b.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *BlacklistClient) DeleteOneID(id int) *BlacklistDeleteOne { + builder := c.Delete().Where(blacklist.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &BlacklistDeleteOne{builder} +} + +// Query returns a query builder for Blacklist. +func (c *BlacklistClient) Query() *BlacklistQuery { + return &BlacklistQuery{ + config: c.config, + } +} + +// Get returns a Blacklist entity by its id. +func (c *BlacklistClient) Get(ctx context.Context, id int) (*Blacklist, error) { + return c.Query().Where(blacklist.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *BlacklistClient) GetX(ctx context.Context, id int) *Blacklist { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *BlacklistClient) Hooks() []Hook { + return c.hooks.Blacklist +} + +// LoggingClient is a client for the Logging schema. +type LoggingClient struct { + config +} + +// NewLoggingClient returns a client for the Logging from the given config. +func NewLoggingClient(c config) *LoggingClient { + return &LoggingClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `logging.Hooks(f(g(h())))`. +func (c *LoggingClient) Use(hooks ...Hook) { + c.hooks.Logging = append(c.hooks.Logging, hooks...) +} + +// Create returns a builder for creating a Logging entity. +func (c *LoggingClient) Create() *LoggingCreate { + mutation := newLoggingMutation(c.config, OpCreate) + return &LoggingCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Logging entities. +func (c *LoggingClient) CreateBulk(builders ...*LoggingCreate) *LoggingCreateBulk { + return &LoggingCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Logging. +func (c *LoggingClient) Update() *LoggingUpdate { + mutation := newLoggingMutation(c.config, OpUpdate) + return &LoggingUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *LoggingClient) UpdateOne(l *Logging) *LoggingUpdateOne { + mutation := newLoggingMutation(c.config, OpUpdateOne, withLogging(l)) + return &LoggingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *LoggingClient) UpdateOneID(id int) *LoggingUpdateOne { + mutation := newLoggingMutation(c.config, OpUpdateOne, withLoggingID(id)) + return &LoggingUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Logging. +func (c *LoggingClient) Delete() *LoggingDelete { + mutation := newLoggingMutation(c.config, OpDelete) + return &LoggingDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *LoggingClient) DeleteOne(l *Logging) *LoggingDeleteOne { + return c.DeleteOneID(l.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *LoggingClient) DeleteOneID(id int) *LoggingDeleteOne { + builder := c.Delete().Where(logging.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &LoggingDeleteOne{builder} +} + +// Query returns a query builder for Logging. +func (c *LoggingClient) Query() *LoggingQuery { + return &LoggingQuery{ + config: c.config, + } +} + +// Get returns a Logging entity by its id. +func (c *LoggingClient) Get(ctx context.Context, id int) (*Logging, error) { + return c.Query().Where(logging.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *LoggingClient) GetX(ctx context.Context, id int) *Logging { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *LoggingClient) Hooks() []Hook { + return c.hooks.Logging +} + +// PunishmentsClient is a client for the Punishments schema. +type PunishmentsClient struct { + config +} + +// NewPunishmentsClient returns a client for the Punishments from the given config. +func NewPunishmentsClient(c config) *PunishmentsClient { + return &PunishmentsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `punishments.Hooks(f(g(h())))`. +func (c *PunishmentsClient) Use(hooks ...Hook) { + c.hooks.Punishments = append(c.hooks.Punishments, hooks...) +} + +// Create returns a builder for creating a Punishments entity. +func (c *PunishmentsClient) Create() *PunishmentsCreate { + mutation := newPunishmentsMutation(c.config, OpCreate) + return &PunishmentsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Punishments entities. +func (c *PunishmentsClient) CreateBulk(builders ...*PunishmentsCreate) *PunishmentsCreateBulk { + return &PunishmentsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Punishments. +func (c *PunishmentsClient) Update() *PunishmentsUpdate { + mutation := newPunishmentsMutation(c.config, OpUpdate) + return &PunishmentsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *PunishmentsClient) UpdateOne(pu *Punishments) *PunishmentsUpdateOne { + mutation := newPunishmentsMutation(c.config, OpUpdateOne, withPunishments(pu)) + return &PunishmentsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *PunishmentsClient) UpdateOneID(id int) *PunishmentsUpdateOne { + mutation := newPunishmentsMutation(c.config, OpUpdateOne, withPunishmentsID(id)) + return &PunishmentsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Punishments. +func (c *PunishmentsClient) Delete() *PunishmentsDelete { + mutation := newPunishmentsMutation(c.config, OpDelete) + return &PunishmentsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *PunishmentsClient) DeleteOne(pu *Punishments) *PunishmentsDeleteOne { + return c.DeleteOneID(pu.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *PunishmentsClient) DeleteOneID(id int) *PunishmentsDeleteOne { + builder := c.Delete().Where(punishments.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &PunishmentsDeleteOne{builder} +} + +// Query returns a query builder for Punishments. +func (c *PunishmentsClient) Query() *PunishmentsQuery { + return &PunishmentsQuery{ + config: c.config, + } +} + +// Get returns a Punishments entity by its id. +func (c *PunishmentsClient) Get(ctx context.Context, id int) (*Punishments, error) { + return c.Query().Where(punishments.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *PunishmentsClient) GetX(ctx context.Context, id int) *Punishments { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *PunishmentsClient) Hooks() []Hook { + return c.hooks.Punishments +} + +// ServersClient is a client for the Servers schema. +type ServersClient struct { + config +} + +// NewServersClient returns a client for the Servers from the given config. +func NewServersClient(c config) *ServersClient { + return &ServersClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `servers.Hooks(f(g(h())))`. +func (c *ServersClient) Use(hooks ...Hook) { + c.hooks.Servers = append(c.hooks.Servers, hooks...) +} + +// Create returns a builder for creating a Servers entity. +func (c *ServersClient) Create() *ServersCreate { + mutation := newServersMutation(c.config, OpCreate) + return &ServersCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Servers entities. +func (c *ServersClient) CreateBulk(builders ...*ServersCreate) *ServersCreateBulk { + return &ServersCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Servers. +func (c *ServersClient) Update() *ServersUpdate { + mutation := newServersMutation(c.config, OpUpdate) + return &ServersUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *ServersClient) UpdateOne(s *Servers) *ServersUpdateOne { + mutation := newServersMutation(c.config, OpUpdateOne, withServers(s)) + return &ServersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *ServersClient) UpdateOneID(id int) *ServersUpdateOne { + mutation := newServersMutation(c.config, OpUpdateOne, withServersID(id)) + return &ServersUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Servers. +func (c *ServersClient) Delete() *ServersDelete { + mutation := newServersMutation(c.config, OpDelete) + return &ServersDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *ServersClient) DeleteOne(s *Servers) *ServersDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *ServersClient) DeleteOneID(id int) *ServersDeleteOne { + builder := c.Delete().Where(servers.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &ServersDeleteOne{builder} +} + +// Query returns a query builder for Servers. +func (c *ServersClient) Query() *ServersQuery { + return &ServersQuery{ + config: c.config, + } +} + +// Get returns a Servers entity by its id. +func (c *ServersClient) Get(ctx context.Context, id int) (*Servers, error) { + return c.Query().Where(servers.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *ServersClient) GetX(ctx context.Context, id int) *Servers { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *ServersClient) Hooks() []Hook { + return c.hooks.Servers +} + +// SettingsClient is a client for the Settings schema. +type SettingsClient struct { + config +} + +// NewSettingsClient returns a client for the Settings from the given config. +func NewSettingsClient(c config) *SettingsClient { + return &SettingsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `settings.Hooks(f(g(h())))`. +func (c *SettingsClient) Use(hooks ...Hook) { + c.hooks.Settings = append(c.hooks.Settings, hooks...) +} + +// Create returns a builder for creating a Settings entity. +func (c *SettingsClient) Create() *SettingsCreate { + mutation := newSettingsMutation(c.config, OpCreate) + return &SettingsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Settings entities. +func (c *SettingsClient) CreateBulk(builders ...*SettingsCreate) *SettingsCreateBulk { + return &SettingsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Settings. +func (c *SettingsClient) Update() *SettingsUpdate { + mutation := newSettingsMutation(c.config, OpUpdate) + return &SettingsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SettingsClient) UpdateOne(s *Settings) *SettingsUpdateOne { + mutation := newSettingsMutation(c.config, OpUpdateOne, withSettings(s)) + return &SettingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SettingsClient) UpdateOneID(id int) *SettingsUpdateOne { + mutation := newSettingsMutation(c.config, OpUpdateOne, withSettingsID(id)) + return &SettingsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Settings. +func (c *SettingsClient) Delete() *SettingsDelete { + mutation := newSettingsMutation(c.config, OpDelete) + return &SettingsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SettingsClient) DeleteOne(s *Settings) *SettingsDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *SettingsClient) DeleteOneID(id int) *SettingsDeleteOne { + builder := c.Delete().Where(settings.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SettingsDeleteOne{builder} +} + +// Query returns a query builder for Settings. +func (c *SettingsClient) Query() *SettingsQuery { + return &SettingsQuery{ + config: c.config, + } +} + +// Get returns a Settings entity by its id. +func (c *SettingsClient) Get(ctx context.Context, id int) (*Settings, error) { + return c.Query().Where(settings.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SettingsClient) GetX(ctx context.Context, id int) *Settings { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *SettingsClient) Hooks() []Hook { + return c.hooks.Settings +} + +// SocialmediaClient is a client for the Socialmedia schema. +type SocialmediaClient struct { + config +} + +// NewSocialmediaClient returns a client for the Socialmedia from the given config. +func NewSocialmediaClient(c config) *SocialmediaClient { + return &SocialmediaClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `socialmedia.Hooks(f(g(h())))`. +func (c *SocialmediaClient) Use(hooks ...Hook) { + c.hooks.Socialmedia = append(c.hooks.Socialmedia, hooks...) +} + +// Create returns a builder for creating a Socialmedia entity. +func (c *SocialmediaClient) Create() *SocialmediaCreate { + mutation := newSocialmediaMutation(c.config, OpCreate) + return &SocialmediaCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Socialmedia entities. +func (c *SocialmediaClient) CreateBulk(builders ...*SocialmediaCreate) *SocialmediaCreateBulk { + return &SocialmediaCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Socialmedia. +func (c *SocialmediaClient) Update() *SocialmediaUpdate { + mutation := newSocialmediaMutation(c.config, OpUpdate) + return &SocialmediaUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SocialmediaClient) UpdateOne(s *Socialmedia) *SocialmediaUpdateOne { + mutation := newSocialmediaMutation(c.config, OpUpdateOne, withSocialmedia(s)) + return &SocialmediaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SocialmediaClient) UpdateOneID(id int) *SocialmediaUpdateOne { + mutation := newSocialmediaMutation(c.config, OpUpdateOne, withSocialmediaID(id)) + return &SocialmediaUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Socialmedia. +func (c *SocialmediaClient) Delete() *SocialmediaDelete { + mutation := newSocialmediaMutation(c.config, OpDelete) + return &SocialmediaDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SocialmediaClient) DeleteOne(s *Socialmedia) *SocialmediaDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *SocialmediaClient) DeleteOneID(id int) *SocialmediaDeleteOne { + builder := c.Delete().Where(socialmedia.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SocialmediaDeleteOne{builder} +} + +// Query returns a query builder for Socialmedia. +func (c *SocialmediaClient) Query() *SocialmediaQuery { + return &SocialmediaQuery{ + config: c.config, + } +} + +// Get returns a Socialmedia entity by its id. +func (c *SocialmediaClient) Get(ctx context.Context, id int) (*Socialmedia, error) { + return c.Query().Where(socialmedia.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SocialmediaClient) GetX(ctx context.Context, id int) *Socialmedia { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *SocialmediaClient) Hooks() []Hook { + return c.hooks.Socialmedia +} + +// SupportClient is a client for the Support schema. +type SupportClient struct { + config +} + +// NewSupportClient returns a client for the Support from the given config. +func NewSupportClient(c config) *SupportClient { + return &SupportClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `support.Hooks(f(g(h())))`. +func (c *SupportClient) Use(hooks ...Hook) { + c.hooks.Support = append(c.hooks.Support, hooks...) +} + +// Create returns a builder for creating a Support entity. +func (c *SupportClient) Create() *SupportCreate { + mutation := newSupportMutation(c.config, OpCreate) + return &SupportCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Support entities. +func (c *SupportClient) CreateBulk(builders ...*SupportCreate) *SupportCreateBulk { + return &SupportCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Support. +func (c *SupportClient) Update() *SupportUpdate { + mutation := newSupportMutation(c.config, OpUpdate) + return &SupportUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SupportClient) UpdateOne(s *Support) *SupportUpdateOne { + mutation := newSupportMutation(c.config, OpUpdateOne, withSupport(s)) + return &SupportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SupportClient) UpdateOneID(id int) *SupportUpdateOne { + mutation := newSupportMutation(c.config, OpUpdateOne, withSupportID(id)) + return &SupportUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Support. +func (c *SupportClient) Delete() *SupportDelete { + mutation := newSupportMutation(c.config, OpDelete) + return &SupportDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SupportClient) DeleteOne(s *Support) *SupportDeleteOne { + return c.DeleteOneID(s.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *SupportClient) DeleteOneID(id int) *SupportDeleteOne { + builder := c.Delete().Where(support.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SupportDeleteOne{builder} +} + +// Query returns a query builder for Support. +func (c *SupportClient) Query() *SupportQuery { + return &SupportQuery{ + config: c.config, + } +} + +// Get returns a Support entity by its id. +func (c *SupportClient) Get(ctx context.Context, id int) (*Support, error) { + return c.Query().Where(support.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SupportClient) GetX(ctx context.Context, id int) *Support { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *SupportClient) Hooks() []Hook { + return c.hooks.Support +} + +// SupportResponseClient is a client for the SupportResponse schema. +type SupportResponseClient struct { + config +} + +// NewSupportResponseClient returns a client for the SupportResponse from the given config. +func NewSupportResponseClient(c config) *SupportResponseClient { + return &SupportResponseClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `supportresponse.Hooks(f(g(h())))`. +func (c *SupportResponseClient) Use(hooks ...Hook) { + c.hooks.SupportResponse = append(c.hooks.SupportResponse, hooks...) +} + +// Create returns a builder for creating a SupportResponse entity. +func (c *SupportResponseClient) Create() *SupportResponseCreate { + mutation := newSupportResponseMutation(c.config, OpCreate) + return &SupportResponseCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of SupportResponse entities. +func (c *SupportResponseClient) CreateBulk(builders ...*SupportResponseCreate) *SupportResponseCreateBulk { + return &SupportResponseCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for SupportResponse. +func (c *SupportResponseClient) Update() *SupportResponseUpdate { + mutation := newSupportResponseMutation(c.config, OpUpdate) + return &SupportResponseUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *SupportResponseClient) UpdateOne(sr *SupportResponse) *SupportResponseUpdateOne { + mutation := newSupportResponseMutation(c.config, OpUpdateOne, withSupportResponse(sr)) + return &SupportResponseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *SupportResponseClient) UpdateOneID(id int) *SupportResponseUpdateOne { + mutation := newSupportResponseMutation(c.config, OpUpdateOne, withSupportResponseID(id)) + return &SupportResponseUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for SupportResponse. +func (c *SupportResponseClient) Delete() *SupportResponseDelete { + mutation := newSupportResponseMutation(c.config, OpDelete) + return &SupportResponseDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *SupportResponseClient) DeleteOne(sr *SupportResponse) *SupportResponseDeleteOne { + return c.DeleteOneID(sr.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *SupportResponseClient) DeleteOneID(id int) *SupportResponseDeleteOne { + builder := c.Delete().Where(supportresponse.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &SupportResponseDeleteOne{builder} +} + +// Query returns a query builder for SupportResponse. +func (c *SupportResponseClient) Query() *SupportResponseQuery { + return &SupportResponseQuery{ + config: c.config, + } +} + +// Get returns a SupportResponse entity by its id. +func (c *SupportResponseClient) Get(ctx context.Context, id int) (*SupportResponse, error) { + return c.Query().Where(supportresponse.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *SupportResponseClient) GetX(ctx context.Context, id int) *SupportResponse { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *SupportResponseClient) Hooks() []Hook { + return c.hooks.SupportResponse +} + +// UserClient is a client for the User schema. +type UserClient struct { + config +} + +// NewUserClient returns a client for the User from the given config. +func NewUserClient(c config) *UserClient { + return &UserClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `user.Hooks(f(g(h())))`. +func (c *UserClient) Use(hooks ...Hook) { + c.hooks.User = append(c.hooks.User, hooks...) +} + +// Create returns a builder for creating a User entity. +func (c *UserClient) Create() *UserCreate { + mutation := newUserMutation(c.config, OpCreate) + return &UserCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of User entities. +func (c *UserClient) CreateBulk(builders ...*UserCreate) *UserCreateBulk { + return &UserCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for User. +func (c *UserClient) Update() *UserUpdate { + mutation := newUserMutation(c.config, OpUpdate) + return &UserUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *UserClient) UpdateOne(u *User) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUser(u)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *UserClient) UpdateOneID(id int) *UserUpdateOne { + mutation := newUserMutation(c.config, OpUpdateOne, withUserID(id)) + return &UserUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for User. +func (c *UserClient) Delete() *UserDelete { + mutation := newUserMutation(c.config, OpDelete) + return &UserDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *UserClient) DeleteOne(u *User) *UserDeleteOne { + return c.DeleteOneID(u.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *UserClient) DeleteOneID(id int) *UserDeleteOne { + builder := c.Delete().Where(user.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &UserDeleteOne{builder} +} + +// Query returns a query builder for User. +func (c *UserClient) Query() *UserQuery { + return &UserQuery{ + config: c.config, + } +} + +// Get returns a User entity by its id. +func (c *UserClient) Get(ctx context.Context, id int) (*User, error) { + return c.Query().Where(user.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *UserClient) GetX(ctx context.Context, id int) *User { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *UserClient) Hooks() []Hook { + return c.hooks.User +} + +// WarnsClient is a client for the Warns schema. +type WarnsClient struct { + config +} + +// NewWarnsClient returns a client for the Warns from the given config. +func NewWarnsClient(c config) *WarnsClient { + return &WarnsClient{config: c} +} + +// Use adds a list of mutation hooks to the hooks stack. +// A call to `Use(f, g, h)` equals to `warns.Hooks(f(g(h())))`. +func (c *WarnsClient) Use(hooks ...Hook) { + c.hooks.Warns = append(c.hooks.Warns, hooks...) +} + +// Create returns a builder for creating a Warns entity. +func (c *WarnsClient) Create() *WarnsCreate { + mutation := newWarnsMutation(c.config, OpCreate) + return &WarnsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// CreateBulk returns a builder for creating a bulk of Warns entities. +func (c *WarnsClient) CreateBulk(builders ...*WarnsCreate) *WarnsCreateBulk { + return &WarnsCreateBulk{config: c.config, builders: builders} +} + +// Update returns an update builder for Warns. +func (c *WarnsClient) Update() *WarnsUpdate { + mutation := newWarnsMutation(c.config, OpUpdate) + return &WarnsUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOne returns an update builder for the given entity. +func (c *WarnsClient) UpdateOne(w *Warns) *WarnsUpdateOne { + mutation := newWarnsMutation(c.config, OpUpdateOne, withWarns(w)) + return &WarnsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// UpdateOneID returns an update builder for the given id. +func (c *WarnsClient) UpdateOneID(id int) *WarnsUpdateOne { + mutation := newWarnsMutation(c.config, OpUpdateOne, withWarnsID(id)) + return &WarnsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// Delete returns a delete builder for Warns. +func (c *WarnsClient) Delete() *WarnsDelete { + mutation := newWarnsMutation(c.config, OpDelete) + return &WarnsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation} +} + +// DeleteOne returns a builder for deleting the given entity. +func (c *WarnsClient) DeleteOne(w *Warns) *WarnsDeleteOne { + return c.DeleteOneID(w.ID) +} + +// DeleteOne returns a builder for deleting the given entity by its id. +func (c *WarnsClient) DeleteOneID(id int) *WarnsDeleteOne { + builder := c.Delete().Where(warns.ID(id)) + builder.mutation.id = &id + builder.mutation.op = OpDeleteOne + return &WarnsDeleteOne{builder} +} + +// Query returns a query builder for Warns. +func (c *WarnsClient) Query() *WarnsQuery { + return &WarnsQuery{ + config: c.config, + } +} + +// Get returns a Warns entity by its id. +func (c *WarnsClient) Get(ctx context.Context, id int) (*Warns, error) { + return c.Query().Where(warns.ID(id)).Only(ctx) +} + +// GetX is like Get, but panics if an error occurs. +func (c *WarnsClient) GetX(ctx context.Context, id int) *Warns { + obj, err := c.Get(ctx, id) + if err != nil { + panic(err) + } + return obj +} + +// Hooks returns the client hooks. +func (c *WarnsClient) Hooks() []Hook { + return c.hooks.Warns +} diff --git a/ent/config.go b/ent/config.go new file mode 100644 index 0000000..199a5d4 --- /dev/null +++ b/ent/config.go @@ -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 + } +} diff --git a/ent/context.go b/ent/context.go new file mode 100644 index 0000000..7811bfa --- /dev/null +++ b/ent/context.go @@ -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) +} diff --git a/ent/ent.go b/ent/ent.go new file mode 100644 index 0000000..b934177 --- /dev/null +++ b/ent/ent.go @@ -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) diff --git a/ent/enttest/enttest.go b/ent/enttest/enttest.go new file mode 100644 index 0000000..61e9ed0 --- /dev/null +++ b/ent/enttest/enttest.go @@ -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() + } +} diff --git a/ent/generate.go b/ent/generate.go new file mode 100644 index 0000000..8d3fdfd --- /dev/null +++ b/ent/generate.go @@ -0,0 +1,3 @@ +package ent + +//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate ./schema diff --git a/ent/hook/hook.go b/ent/hook/hook.go new file mode 100644 index 0000000..29add74 --- /dev/null +++ b/ent/hook/hook.go @@ -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...) +} diff --git a/ent/logging.go b/ent/logging.go new file mode 100644 index 0000000..2da8a21 --- /dev/null +++ b/ent/logging.go @@ -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 + } +} diff --git a/ent/logging/logging.go b/ent/logging/logging.go new file mode 100644 index 0000000..ac7e1f1 --- /dev/null +++ b/ent/logging/logging.go @@ -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 +} diff --git a/ent/logging/where.go b/ent/logging/where.go new file mode 100644 index 0000000..fe31794 --- /dev/null +++ b/ent/logging/where.go @@ -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()) + }) +} diff --git a/ent/logging_create.go b/ent/logging_create.go new file mode 100644 index 0000000..9d6fbc5 --- /dev/null +++ b/ent/logging_create.go @@ -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) + } +} diff --git a/ent/logging_delete.go b/ent/logging_delete.go new file mode 100644 index 0000000..f407640 --- /dev/null +++ b/ent/logging_delete.go @@ -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) +} diff --git a/ent/logging_query.go b/ent/logging_query.go new file mode 100644 index 0000000..6de3336 --- /dev/null +++ b/ent/logging_query.go @@ -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) +} diff --git a/ent/logging_update.go b/ent/logging_update.go new file mode 100644 index 0000000..d548ffc --- /dev/null +++ b/ent/logging_update.go @@ -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 +} diff --git a/ent/migrate/migrate.go b/ent/migrate/migrate.go new file mode 100644 index 0000000..6bccf39 --- /dev/null +++ b/ent/migrate/migrate.go @@ -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...) +} diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go new file mode 100644 index 0000000..c0894f0 --- /dev/null +++ b/ent/migrate/schema.go @@ -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() { +} diff --git a/ent/mutation.go b/ent/mutation.go new file mode 100644 index 0000000..cb5ed26 --- /dev/null +++ b/ent/mutation.go @@ -0,0 +1,7730 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "context" + "errors" + "fmt" + "sync" + "time" + + "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/predicate" + "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" + + "entgo.io/ent" +) + +const ( + // Operation types. + OpCreate = ent.OpCreate + OpDelete = ent.OpDelete + OpDeleteOne = ent.OpDeleteOne + OpUpdate = ent.OpUpdate + OpUpdateOne = ent.OpUpdateOne + + // Node types. + TypeActions = "Actions" + TypeAuthorizables = "Authorizables" + TypeBlacklist = "Blacklist" + TypeLogging = "Logging" + TypePunishments = "Punishments" + TypeServers = "Servers" + TypeSettings = "Settings" + TypeSocialmedia = "Socialmedia" + TypeSupport = "Support" + TypeSupportResponse = "SupportResponse" + TypeUser = "User" + TypeWarns = "Warns" +) + +// ActionsMutation represents an operation that mutates the Actions nodes in the graph. +type ActionsMutation struct { + config + op Op + typ string + id *int + refid *string + commiter *string + serverid *string + target *string + _type *string + duration *string + reason *string + temp *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Actions, error) + predicates []predicate.Actions +} + +var _ ent.Mutation = (*ActionsMutation)(nil) + +// actionsOption allows management of the mutation configuration using functional options. +type actionsOption func(*ActionsMutation) + +// newActionsMutation creates new mutation for the Actions entity. +func newActionsMutation(c config, op Op, opts ...actionsOption) *ActionsMutation { + m := &ActionsMutation{ + config: c, + op: op, + typ: TypeActions, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withActionsID sets the ID field of the mutation. +func withActionsID(id int) actionsOption { + return func(m *ActionsMutation) { + var ( + err error + once sync.Once + value *Actions + ) + m.oldValue = func(ctx context.Context) (*Actions, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Actions.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withActions sets the old Actions of the mutation. +func withActions(node *Actions) actionsOption { + return func(m *ActionsMutation) { + m.oldValue = func(context.Context) (*Actions, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ActionsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ActionsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Actions entities. +func (m *ActionsMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ActionsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ActionsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Actions.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRefid sets the "refid" field. +func (m *ActionsMutation) SetRefid(s string) { + m.refid = &s +} + +// Refid returns the value of the "refid" field in the mutation. +func (m *ActionsMutation) Refid() (r string, exists bool) { + v := m.refid + if v == nil { + return + } + return *v, true +} + +// OldRefid returns the old "refid" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldRefid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefid: %w", err) + } + return oldValue.Refid, nil +} + +// ResetRefid resets all changes to the "refid" field. +func (m *ActionsMutation) ResetRefid() { + m.refid = nil +} + +// SetCommiter sets the "commiter" field. +func (m *ActionsMutation) SetCommiter(s string) { + m.commiter = &s +} + +// Commiter returns the value of the "commiter" field in the mutation. +func (m *ActionsMutation) Commiter() (r string, exists bool) { + v := m.commiter + if v == nil { + return + } + return *v, true +} + +// OldCommiter returns the old "commiter" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldCommiter(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCommiter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCommiter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCommiter: %w", err) + } + return oldValue.Commiter, nil +} + +// ResetCommiter resets all changes to the "commiter" field. +func (m *ActionsMutation) ResetCommiter() { + m.commiter = nil +} + +// SetServerid sets the "serverid" field. +func (m *ActionsMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *ActionsMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *ActionsMutation) ResetServerid() { + m.serverid = nil +} + +// SetTarget sets the "target" field. +func (m *ActionsMutation) SetTarget(s string) { + m.target = &s +} + +// Target returns the value of the "target" field in the mutation. +func (m *ActionsMutation) Target() (r string, exists bool) { + v := m.target + if v == nil { + return + } + return *v, true +} + +// OldTarget returns the old "target" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldTarget(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTarget is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTarget requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTarget: %w", err) + } + return oldValue.Target, nil +} + +// ResetTarget resets all changes to the "target" field. +func (m *ActionsMutation) ResetTarget() { + m.target = nil +} + +// SetType sets the "type" field. +func (m *ActionsMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *ActionsMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *ActionsMutation) ResetType() { + m._type = nil +} + +// SetDuration sets the "duration" field. +func (m *ActionsMutation) SetDuration(s string) { + m.duration = &s +} + +// Duration returns the value of the "duration" field in the mutation. +func (m *ActionsMutation) Duration() (r string, exists bool) { + v := m.duration + if v == nil { + return + } + return *v, true +} + +// OldDuration returns the old "duration" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldDuration(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDuration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDuration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDuration: %w", err) + } + return oldValue.Duration, nil +} + +// ResetDuration resets all changes to the "duration" field. +func (m *ActionsMutation) ResetDuration() { + m.duration = nil +} + +// SetReason sets the "reason" field. +func (m *ActionsMutation) SetReason(s string) { + m.reason = &s +} + +// Reason returns the value of the "reason" field in the mutation. +func (m *ActionsMutation) Reason() (r string, exists bool) { + v := m.reason + if v == nil { + return + } + return *v, true +} + +// OldReason returns the old "reason" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReason: %w", err) + } + return oldValue.Reason, nil +} + +// ResetReason resets all changes to the "reason" field. +func (m *ActionsMutation) ResetReason() { + m.reason = nil +} + +// SetTemp sets the "temp" field. +func (m *ActionsMutation) SetTemp(b bool) { + m.temp = &b +} + +// Temp returns the value of the "temp" field in the mutation. +func (m *ActionsMutation) Temp() (r bool, exists bool) { + v := m.temp + if v == nil { + return + } + return *v, true +} + +// OldTemp returns the old "temp" field's value of the Actions entity. +// If the Actions object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ActionsMutation) OldTemp(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTemp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTemp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTemp: %w", err) + } + return oldValue.Temp, nil +} + +// ResetTemp resets all changes to the "temp" field. +func (m *ActionsMutation) ResetTemp() { + m.temp = nil +} + +// Where appends a list predicates to the ActionsMutation builder. +func (m *ActionsMutation) Where(ps ...predicate.Actions) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *ActionsMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Actions). +func (m *ActionsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ActionsMutation) Fields() []string { + fields := make([]string, 0, 8) + if m.refid != nil { + fields = append(fields, actions.FieldRefid) + } + if m.commiter != nil { + fields = append(fields, actions.FieldCommiter) + } + if m.serverid != nil { + fields = append(fields, actions.FieldServerid) + } + if m.target != nil { + fields = append(fields, actions.FieldTarget) + } + if m._type != nil { + fields = append(fields, actions.FieldType) + } + if m.duration != nil { + fields = append(fields, actions.FieldDuration) + } + if m.reason != nil { + fields = append(fields, actions.FieldReason) + } + if m.temp != nil { + fields = append(fields, actions.FieldTemp) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ActionsMutation) Field(name string) (ent.Value, bool) { + switch name { + case actions.FieldRefid: + return m.Refid() + case actions.FieldCommiter: + return m.Commiter() + case actions.FieldServerid: + return m.Serverid() + case actions.FieldTarget: + return m.Target() + case actions.FieldType: + return m.GetType() + case actions.FieldDuration: + return m.Duration() + case actions.FieldReason: + return m.Reason() + case actions.FieldTemp: + return m.Temp() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ActionsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case actions.FieldRefid: + return m.OldRefid(ctx) + case actions.FieldCommiter: + return m.OldCommiter(ctx) + case actions.FieldServerid: + return m.OldServerid(ctx) + case actions.FieldTarget: + return m.OldTarget(ctx) + case actions.FieldType: + return m.OldType(ctx) + case actions.FieldDuration: + return m.OldDuration(ctx) + case actions.FieldReason: + return m.OldReason(ctx) + case actions.FieldTemp: + return m.OldTemp(ctx) + } + return nil, fmt.Errorf("unknown Actions field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ActionsMutation) SetField(name string, value ent.Value) error { + switch name { + case actions.FieldRefid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefid(v) + return nil + case actions.FieldCommiter: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCommiter(v) + return nil + case actions.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case actions.FieldTarget: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTarget(v) + return nil + case actions.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case actions.FieldDuration: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDuration(v) + return nil + case actions.FieldReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReason(v) + return nil + case actions.FieldTemp: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTemp(v) + return nil + } + return fmt.Errorf("unknown Actions field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ActionsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ActionsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ActionsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Actions numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ActionsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ActionsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ActionsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Actions nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ActionsMutation) ResetField(name string) error { + switch name { + case actions.FieldRefid: + m.ResetRefid() + return nil + case actions.FieldCommiter: + m.ResetCommiter() + return nil + case actions.FieldServerid: + m.ResetServerid() + return nil + case actions.FieldTarget: + m.ResetTarget() + return nil + case actions.FieldType: + m.ResetType() + return nil + case actions.FieldDuration: + m.ResetDuration() + return nil + case actions.FieldReason: + m.ResetReason() + return nil + case actions.FieldTemp: + m.ResetTemp() + return nil + } + return fmt.Errorf("unknown Actions field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ActionsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ActionsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ActionsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ActionsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ActionsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ActionsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ActionsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Actions unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ActionsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Actions edge %s", name) +} + +// AuthorizablesMutation represents an operation that mutates the Authorizables nodes in the graph. +type AuthorizablesMutation struct { + config + op Op + typ string + id *int + username *string + password *string + serverid *string + userid *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Authorizables, error) + predicates []predicate.Authorizables +} + +var _ ent.Mutation = (*AuthorizablesMutation)(nil) + +// authorizablesOption allows management of the mutation configuration using functional options. +type authorizablesOption func(*AuthorizablesMutation) + +// newAuthorizablesMutation creates new mutation for the Authorizables entity. +func newAuthorizablesMutation(c config, op Op, opts ...authorizablesOption) *AuthorizablesMutation { + m := &AuthorizablesMutation{ + config: c, + op: op, + typ: TypeAuthorizables, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withAuthorizablesID sets the ID field of the mutation. +func withAuthorizablesID(id int) authorizablesOption { + return func(m *AuthorizablesMutation) { + var ( + err error + once sync.Once + value *Authorizables + ) + m.oldValue = func(ctx context.Context) (*Authorizables, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Authorizables.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withAuthorizables sets the old Authorizables of the mutation. +func withAuthorizables(node *Authorizables) authorizablesOption { + return func(m *AuthorizablesMutation) { + m.oldValue = func(context.Context) (*Authorizables, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m AuthorizablesMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m AuthorizablesMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *AuthorizablesMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *AuthorizablesMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Authorizables.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUsername sets the "username" field. +func (m *AuthorizablesMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *AuthorizablesMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the Authorizables entity. +// If the Authorizables object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorizablesMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ResetUsername resets all changes to the "username" field. +func (m *AuthorizablesMutation) ResetUsername() { + m.username = nil +} + +// SetPassword sets the "password" field. +func (m *AuthorizablesMutation) SetPassword(s string) { + m.password = &s +} + +// Password returns the value of the "password" field in the mutation. +func (m *AuthorizablesMutation) Password() (r string, exists bool) { + v := m.password + if v == nil { + return + } + return *v, true +} + +// OldPassword returns the old "password" field's value of the Authorizables entity. +// If the Authorizables object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorizablesMutation) OldPassword(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPassword is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPassword requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPassword: %w", err) + } + return oldValue.Password, nil +} + +// ResetPassword resets all changes to the "password" field. +func (m *AuthorizablesMutation) ResetPassword() { + m.password = nil +} + +// SetServerid sets the "serverid" field. +func (m *AuthorizablesMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *AuthorizablesMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Authorizables entity. +// If the Authorizables object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorizablesMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *AuthorizablesMutation) ResetServerid() { + m.serverid = nil +} + +// SetUserid sets the "userid" field. +func (m *AuthorizablesMutation) SetUserid(s string) { + m.userid = &s +} + +// Userid returns the value of the "userid" field in the mutation. +func (m *AuthorizablesMutation) Userid() (r string, exists bool) { + v := m.userid + if v == nil { + return + } + return *v, true +} + +// OldUserid returns the old "userid" field's value of the Authorizables entity. +// If the Authorizables object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *AuthorizablesMutation) OldUserid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserid: %w", err) + } + return oldValue.Userid, nil +} + +// ResetUserid resets all changes to the "userid" field. +func (m *AuthorizablesMutation) ResetUserid() { + m.userid = nil +} + +// Where appends a list predicates to the AuthorizablesMutation builder. +func (m *AuthorizablesMutation) Where(ps ...predicate.Authorizables) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *AuthorizablesMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Authorizables). +func (m *AuthorizablesMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *AuthorizablesMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.username != nil { + fields = append(fields, authorizables.FieldUsername) + } + if m.password != nil { + fields = append(fields, authorizables.FieldPassword) + } + if m.serverid != nil { + fields = append(fields, authorizables.FieldServerid) + } + if m.userid != nil { + fields = append(fields, authorizables.FieldUserid) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *AuthorizablesMutation) Field(name string) (ent.Value, bool) { + switch name { + case authorizables.FieldUsername: + return m.Username() + case authorizables.FieldPassword: + return m.Password() + case authorizables.FieldServerid: + return m.Serverid() + case authorizables.FieldUserid: + return m.Userid() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *AuthorizablesMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case authorizables.FieldUsername: + return m.OldUsername(ctx) + case authorizables.FieldPassword: + return m.OldPassword(ctx) + case authorizables.FieldServerid: + return m.OldServerid(ctx) + case authorizables.FieldUserid: + return m.OldUserid(ctx) + } + return nil, fmt.Errorf("unknown Authorizables field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AuthorizablesMutation) SetField(name string, value ent.Value) error { + switch name { + case authorizables.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case authorizables.FieldPassword: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPassword(v) + return nil + case authorizables.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case authorizables.FieldUserid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserid(v) + return nil + } + return fmt.Errorf("unknown Authorizables field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *AuthorizablesMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *AuthorizablesMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *AuthorizablesMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Authorizables numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *AuthorizablesMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *AuthorizablesMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *AuthorizablesMutation) ClearField(name string) error { + return fmt.Errorf("unknown Authorizables nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *AuthorizablesMutation) ResetField(name string) error { + switch name { + case authorizables.FieldUsername: + m.ResetUsername() + return nil + case authorizables.FieldPassword: + m.ResetPassword() + return nil + case authorizables.FieldServerid: + m.ResetServerid() + return nil + case authorizables.FieldUserid: + m.ResetUserid() + return nil + } + return fmt.Errorf("unknown Authorizables field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *AuthorizablesMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *AuthorizablesMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *AuthorizablesMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *AuthorizablesMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *AuthorizablesMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *AuthorizablesMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *AuthorizablesMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Authorizables unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *AuthorizablesMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Authorizables edge %s", name) +} + +// BlacklistMutation represents an operation that mutates the Blacklist nodes in the graph. +type BlacklistMutation struct { + config + op Op + typ string + id *int + serverid *string + word *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Blacklist, error) + predicates []predicate.Blacklist +} + +var _ ent.Mutation = (*BlacklistMutation)(nil) + +// blacklistOption allows management of the mutation configuration using functional options. +type blacklistOption func(*BlacklistMutation) + +// newBlacklistMutation creates new mutation for the Blacklist entity. +func newBlacklistMutation(c config, op Op, opts ...blacklistOption) *BlacklistMutation { + m := &BlacklistMutation{ + config: c, + op: op, + typ: TypeBlacklist, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withBlacklistID sets the ID field of the mutation. +func withBlacklistID(id int) blacklistOption { + return func(m *BlacklistMutation) { + var ( + err error + once sync.Once + value *Blacklist + ) + m.oldValue = func(ctx context.Context) (*Blacklist, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Blacklist.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withBlacklist sets the old Blacklist of the mutation. +func withBlacklist(node *Blacklist) blacklistOption { + return func(m *BlacklistMutation) { + m.oldValue = func(context.Context) (*Blacklist, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m BlacklistMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m BlacklistMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Blacklist entities. +func (m *BlacklistMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *BlacklistMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *BlacklistMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Blacklist.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *BlacklistMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *BlacklistMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Blacklist entity. +// If the Blacklist object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BlacklistMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *BlacklistMutation) ResetServerid() { + m.serverid = nil +} + +// SetWord sets the "word" field. +func (m *BlacklistMutation) SetWord(s string) { + m.word = &s +} + +// Word returns the value of the "word" field in the mutation. +func (m *BlacklistMutation) Word() (r string, exists bool) { + v := m.word + if v == nil { + return + } + return *v, true +} + +// OldWord returns the old "word" field's value of the Blacklist entity. +// If the Blacklist object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *BlacklistMutation) OldWord(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWord is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWord requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWord: %w", err) + } + return oldValue.Word, nil +} + +// ResetWord resets all changes to the "word" field. +func (m *BlacklistMutation) ResetWord() { + m.word = nil +} + +// Where appends a list predicates to the BlacklistMutation builder. +func (m *BlacklistMutation) Where(ps ...predicate.Blacklist) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *BlacklistMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Blacklist). +func (m *BlacklistMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *BlacklistMutation) Fields() []string { + fields := make([]string, 0, 2) + if m.serverid != nil { + fields = append(fields, blacklist.FieldServerid) + } + if m.word != nil { + fields = append(fields, blacklist.FieldWord) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *BlacklistMutation) Field(name string) (ent.Value, bool) { + switch name { + case blacklist.FieldServerid: + return m.Serverid() + case blacklist.FieldWord: + return m.Word() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *BlacklistMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case blacklist.FieldServerid: + return m.OldServerid(ctx) + case blacklist.FieldWord: + return m.OldWord(ctx) + } + return nil, fmt.Errorf("unknown Blacklist field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BlacklistMutation) SetField(name string, value ent.Value) error { + switch name { + case blacklist.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case blacklist.FieldWord: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWord(v) + return nil + } + return fmt.Errorf("unknown Blacklist field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *BlacklistMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *BlacklistMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *BlacklistMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Blacklist numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *BlacklistMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *BlacklistMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *BlacklistMutation) ClearField(name string) error { + return fmt.Errorf("unknown Blacklist nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *BlacklistMutation) ResetField(name string) error { + switch name { + case blacklist.FieldServerid: + m.ResetServerid() + return nil + case blacklist.FieldWord: + m.ResetWord() + return nil + } + return fmt.Errorf("unknown Blacklist field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *BlacklistMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *BlacklistMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *BlacklistMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *BlacklistMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *BlacklistMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *BlacklistMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *BlacklistMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Blacklist unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *BlacklistMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Blacklist edge %s", name) +} + +// LoggingMutation represents an operation that mutates the Logging nodes in the graph. +type LoggingMutation struct { + config + op Op + typ string + id *int + serverid *string + _type *string + commiter *string + description *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Logging, error) + predicates []predicate.Logging +} + +var _ ent.Mutation = (*LoggingMutation)(nil) + +// loggingOption allows management of the mutation configuration using functional options. +type loggingOption func(*LoggingMutation) + +// newLoggingMutation creates new mutation for the Logging entity. +func newLoggingMutation(c config, op Op, opts ...loggingOption) *LoggingMutation { + m := &LoggingMutation{ + config: c, + op: op, + typ: TypeLogging, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withLoggingID sets the ID field of the mutation. +func withLoggingID(id int) loggingOption { + return func(m *LoggingMutation) { + var ( + err error + once sync.Once + value *Logging + ) + m.oldValue = func(ctx context.Context) (*Logging, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Logging.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withLogging sets the old Logging of the mutation. +func withLogging(node *Logging) loggingOption { + return func(m *LoggingMutation) { + m.oldValue = func(context.Context) (*Logging, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m LoggingMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m LoggingMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Logging entities. +func (m *LoggingMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *LoggingMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *LoggingMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Logging.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *LoggingMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *LoggingMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Logging entity. +// If the Logging object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LoggingMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *LoggingMutation) ResetServerid() { + m.serverid = nil +} + +// SetType sets the "type" field. +func (m *LoggingMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *LoggingMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Logging entity. +// If the Logging object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LoggingMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *LoggingMutation) ResetType() { + m._type = nil +} + +// SetCommiter sets the "commiter" field. +func (m *LoggingMutation) SetCommiter(s string) { + m.commiter = &s +} + +// Commiter returns the value of the "commiter" field in the mutation. +func (m *LoggingMutation) Commiter() (r string, exists bool) { + v := m.commiter + if v == nil { + return + } + return *v, true +} + +// OldCommiter returns the old "commiter" field's value of the Logging entity. +// If the Logging object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LoggingMutation) OldCommiter(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCommiter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCommiter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCommiter: %w", err) + } + return oldValue.Commiter, nil +} + +// ResetCommiter resets all changes to the "commiter" field. +func (m *LoggingMutation) ResetCommiter() { + m.commiter = nil +} + +// SetDescription sets the "description" field. +func (m *LoggingMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *LoggingMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Logging entity. +// If the Logging object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *LoggingMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *LoggingMutation) ResetDescription() { + m.description = nil +} + +// Where appends a list predicates to the LoggingMutation builder. +func (m *LoggingMutation) Where(ps ...predicate.Logging) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *LoggingMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Logging). +func (m *LoggingMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *LoggingMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.serverid != nil { + fields = append(fields, logging.FieldServerid) + } + if m._type != nil { + fields = append(fields, logging.FieldType) + } + if m.commiter != nil { + fields = append(fields, logging.FieldCommiter) + } + if m.description != nil { + fields = append(fields, logging.FieldDescription) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *LoggingMutation) Field(name string) (ent.Value, bool) { + switch name { + case logging.FieldServerid: + return m.Serverid() + case logging.FieldType: + return m.GetType() + case logging.FieldCommiter: + return m.Commiter() + case logging.FieldDescription: + return m.Description() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *LoggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case logging.FieldServerid: + return m.OldServerid(ctx) + case logging.FieldType: + return m.OldType(ctx) + case logging.FieldCommiter: + return m.OldCommiter(ctx) + case logging.FieldDescription: + return m.OldDescription(ctx) + } + return nil, fmt.Errorf("unknown Logging field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *LoggingMutation) SetField(name string, value ent.Value) error { + switch name { + case logging.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case logging.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case logging.FieldCommiter: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCommiter(v) + return nil + case logging.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + } + return fmt.Errorf("unknown Logging field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *LoggingMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *LoggingMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *LoggingMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Logging numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *LoggingMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *LoggingMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *LoggingMutation) ClearField(name string) error { + return fmt.Errorf("unknown Logging nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *LoggingMutation) ResetField(name string) error { + switch name { + case logging.FieldServerid: + m.ResetServerid() + return nil + case logging.FieldType: + m.ResetType() + return nil + case logging.FieldCommiter: + m.ResetCommiter() + return nil + case logging.FieldDescription: + m.ResetDescription() + return nil + } + return fmt.Errorf("unknown Logging field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *LoggingMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *LoggingMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *LoggingMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *LoggingMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *LoggingMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *LoggingMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *LoggingMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Logging unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *LoggingMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Logging edge %s", name) +} + +// PunishmentsMutation represents an operation that mutates the Punishments nodes in the graph. +type PunishmentsMutation struct { + config + op Op + typ string + id *int + serverid *string + warnamount *string + actiontype *string + duration *string + reason *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Punishments, error) + predicates []predicate.Punishments +} + +var _ ent.Mutation = (*PunishmentsMutation)(nil) + +// punishmentsOption allows management of the mutation configuration using functional options. +type punishmentsOption func(*PunishmentsMutation) + +// newPunishmentsMutation creates new mutation for the Punishments entity. +func newPunishmentsMutation(c config, op Op, opts ...punishmentsOption) *PunishmentsMutation { + m := &PunishmentsMutation{ + config: c, + op: op, + typ: TypePunishments, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withPunishmentsID sets the ID field of the mutation. +func withPunishmentsID(id int) punishmentsOption { + return func(m *PunishmentsMutation) { + var ( + err error + once sync.Once + value *Punishments + ) + m.oldValue = func(ctx context.Context) (*Punishments, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Punishments.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withPunishments sets the old Punishments of the mutation. +func withPunishments(node *Punishments) punishmentsOption { + return func(m *PunishmentsMutation) { + m.oldValue = func(context.Context) (*Punishments, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m PunishmentsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m PunishmentsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Punishments entities. +func (m *PunishmentsMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *PunishmentsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *PunishmentsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Punishments.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *PunishmentsMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *PunishmentsMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Punishments entity. +// If the Punishments object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PunishmentsMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *PunishmentsMutation) ResetServerid() { + m.serverid = nil +} + +// SetWarnamount sets the "warnamount" field. +func (m *PunishmentsMutation) SetWarnamount(s string) { + m.warnamount = &s +} + +// Warnamount returns the value of the "warnamount" field in the mutation. +func (m *PunishmentsMutation) Warnamount() (r string, exists bool) { + v := m.warnamount + if v == nil { + return + } + return *v, true +} + +// OldWarnamount returns the old "warnamount" field's value of the Punishments entity. +// If the Punishments object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PunishmentsMutation) OldWarnamount(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWarnamount is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWarnamount requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWarnamount: %w", err) + } + return oldValue.Warnamount, nil +} + +// ResetWarnamount resets all changes to the "warnamount" field. +func (m *PunishmentsMutation) ResetWarnamount() { + m.warnamount = nil +} + +// SetActiontype sets the "actiontype" field. +func (m *PunishmentsMutation) SetActiontype(s string) { + m.actiontype = &s +} + +// Actiontype returns the value of the "actiontype" field in the mutation. +func (m *PunishmentsMutation) Actiontype() (r string, exists bool) { + v := m.actiontype + if v == nil { + return + } + return *v, true +} + +// OldActiontype returns the old "actiontype" field's value of the Punishments entity. +// If the Punishments object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PunishmentsMutation) OldActiontype(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldActiontype is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldActiontype requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldActiontype: %w", err) + } + return oldValue.Actiontype, nil +} + +// ResetActiontype resets all changes to the "actiontype" field. +func (m *PunishmentsMutation) ResetActiontype() { + m.actiontype = nil +} + +// SetDuration sets the "duration" field. +func (m *PunishmentsMutation) SetDuration(s string) { + m.duration = &s +} + +// Duration returns the value of the "duration" field in the mutation. +func (m *PunishmentsMutation) Duration() (r string, exists bool) { + v := m.duration + if v == nil { + return + } + return *v, true +} + +// OldDuration returns the old "duration" field's value of the Punishments entity. +// If the Punishments object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PunishmentsMutation) OldDuration(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDuration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDuration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDuration: %w", err) + } + return oldValue.Duration, nil +} + +// ResetDuration resets all changes to the "duration" field. +func (m *PunishmentsMutation) ResetDuration() { + m.duration = nil +} + +// SetReason sets the "reason" field. +func (m *PunishmentsMutation) SetReason(s string) { + m.reason = &s +} + +// Reason returns the value of the "reason" field in the mutation. +func (m *PunishmentsMutation) Reason() (r string, exists bool) { + v := m.reason + if v == nil { + return + } + return *v, true +} + +// OldReason returns the old "reason" field's value of the Punishments entity. +// If the Punishments object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *PunishmentsMutation) OldReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReason: %w", err) + } + return oldValue.Reason, nil +} + +// ResetReason resets all changes to the "reason" field. +func (m *PunishmentsMutation) ResetReason() { + m.reason = nil +} + +// Where appends a list predicates to the PunishmentsMutation builder. +func (m *PunishmentsMutation) Where(ps ...predicate.Punishments) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *PunishmentsMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Punishments). +func (m *PunishmentsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *PunishmentsMutation) Fields() []string { + fields := make([]string, 0, 5) + if m.serverid != nil { + fields = append(fields, punishments.FieldServerid) + } + if m.warnamount != nil { + fields = append(fields, punishments.FieldWarnamount) + } + if m.actiontype != nil { + fields = append(fields, punishments.FieldActiontype) + } + if m.duration != nil { + fields = append(fields, punishments.FieldDuration) + } + if m.reason != nil { + fields = append(fields, punishments.FieldReason) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *PunishmentsMutation) Field(name string) (ent.Value, bool) { + switch name { + case punishments.FieldServerid: + return m.Serverid() + case punishments.FieldWarnamount: + return m.Warnamount() + case punishments.FieldActiontype: + return m.Actiontype() + case punishments.FieldDuration: + return m.Duration() + case punishments.FieldReason: + return m.Reason() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *PunishmentsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case punishments.FieldServerid: + return m.OldServerid(ctx) + case punishments.FieldWarnamount: + return m.OldWarnamount(ctx) + case punishments.FieldActiontype: + return m.OldActiontype(ctx) + case punishments.FieldDuration: + return m.OldDuration(ctx) + case punishments.FieldReason: + return m.OldReason(ctx) + } + return nil, fmt.Errorf("unknown Punishments field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PunishmentsMutation) SetField(name string, value ent.Value) error { + switch name { + case punishments.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case punishments.FieldWarnamount: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWarnamount(v) + return nil + case punishments.FieldActiontype: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetActiontype(v) + return nil + case punishments.FieldDuration: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDuration(v) + return nil + case punishments.FieldReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReason(v) + return nil + } + return fmt.Errorf("unknown Punishments field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *PunishmentsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *PunishmentsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *PunishmentsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Punishments numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *PunishmentsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *PunishmentsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *PunishmentsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Punishments nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *PunishmentsMutation) ResetField(name string) error { + switch name { + case punishments.FieldServerid: + m.ResetServerid() + return nil + case punishments.FieldWarnamount: + m.ResetWarnamount() + return nil + case punishments.FieldActiontype: + m.ResetActiontype() + return nil + case punishments.FieldDuration: + m.ResetDuration() + return nil + case punishments.FieldReason: + m.ResetReason() + return nil + } + return fmt.Errorf("unknown Punishments field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *PunishmentsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *PunishmentsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *PunishmentsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *PunishmentsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *PunishmentsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *PunishmentsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *PunishmentsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Punishments unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *PunishmentsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Punishments edge %s", name) +} + +// ServersMutation represents an operation that mutates the Servers nodes in the graph. +type ServersMutation struct { + config + op Op + typ string + id *int + userid *string + serverid *string + isOwner *bool + permission *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Servers, error) + predicates []predicate.Servers +} + +var _ ent.Mutation = (*ServersMutation)(nil) + +// serversOption allows management of the mutation configuration using functional options. +type serversOption func(*ServersMutation) + +// newServersMutation creates new mutation for the Servers entity. +func newServersMutation(c config, op Op, opts ...serversOption) *ServersMutation { + m := &ServersMutation{ + config: c, + op: op, + typ: TypeServers, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withServersID sets the ID field of the mutation. +func withServersID(id int) serversOption { + return func(m *ServersMutation) { + var ( + err error + once sync.Once + value *Servers + ) + m.oldValue = func(ctx context.Context) (*Servers, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Servers.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withServers sets the old Servers of the mutation. +func withServers(node *Servers) serversOption { + return func(m *ServersMutation) { + m.oldValue = func(context.Context) (*Servers, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m ServersMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m ServersMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Servers entities. +func (m *ServersMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *ServersMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *ServersMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Servers.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetUserid sets the "userid" field. +func (m *ServersMutation) SetUserid(s string) { + m.userid = &s +} + +// Userid returns the value of the "userid" field in the mutation. +func (m *ServersMutation) Userid() (r string, exists bool) { + v := m.userid + if v == nil { + return + } + return *v, true +} + +// OldUserid returns the old "userid" field's value of the Servers entity. +// If the Servers object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServersMutation) OldUserid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserid: %w", err) + } + return oldValue.Userid, nil +} + +// ResetUserid resets all changes to the "userid" field. +func (m *ServersMutation) ResetUserid() { + m.userid = nil +} + +// SetServerid sets the "serverid" field. +func (m *ServersMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *ServersMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Servers entity. +// If the Servers object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServersMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *ServersMutation) ResetServerid() { + m.serverid = nil +} + +// SetIsOwner sets the "isOwner" field. +func (m *ServersMutation) SetIsOwner(b bool) { + m.isOwner = &b +} + +// IsOwner returns the value of the "isOwner" field in the mutation. +func (m *ServersMutation) IsOwner() (r bool, exists bool) { + v := m.isOwner + if v == nil { + return + } + return *v, true +} + +// OldIsOwner returns the old "isOwner" field's value of the Servers entity. +// If the Servers object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServersMutation) OldIsOwner(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsOwner is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsOwner requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsOwner: %w", err) + } + return oldValue.IsOwner, nil +} + +// ResetIsOwner resets all changes to the "isOwner" field. +func (m *ServersMutation) ResetIsOwner() { + m.isOwner = nil +} + +// SetPermission sets the "permission" field. +func (m *ServersMutation) SetPermission(s string) { + m.permission = &s +} + +// Permission returns the value of the "permission" field in the mutation. +func (m *ServersMutation) Permission() (r string, exists bool) { + v := m.permission + if v == nil { + return + } + return *v, true +} + +// OldPermission returns the old "permission" field's value of the Servers entity. +// If the Servers object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *ServersMutation) OldPermission(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermission is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermission requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermission: %w", err) + } + return oldValue.Permission, nil +} + +// ResetPermission resets all changes to the "permission" field. +func (m *ServersMutation) ResetPermission() { + m.permission = nil +} + +// Where appends a list predicates to the ServersMutation builder. +func (m *ServersMutation) Where(ps ...predicate.Servers) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *ServersMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Servers). +func (m *ServersMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *ServersMutation) Fields() []string { + fields := make([]string, 0, 4) + if m.userid != nil { + fields = append(fields, servers.FieldUserid) + } + if m.serverid != nil { + fields = append(fields, servers.FieldServerid) + } + if m.isOwner != nil { + fields = append(fields, servers.FieldIsOwner) + } + if m.permission != nil { + fields = append(fields, servers.FieldPermission) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *ServersMutation) Field(name string) (ent.Value, bool) { + switch name { + case servers.FieldUserid: + return m.Userid() + case servers.FieldServerid: + return m.Serverid() + case servers.FieldIsOwner: + return m.IsOwner() + case servers.FieldPermission: + return m.Permission() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *ServersMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case servers.FieldUserid: + return m.OldUserid(ctx) + case servers.FieldServerid: + return m.OldServerid(ctx) + case servers.FieldIsOwner: + return m.OldIsOwner(ctx) + case servers.FieldPermission: + return m.OldPermission(ctx) + } + return nil, fmt.Errorf("unknown Servers field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ServersMutation) SetField(name string, value ent.Value) error { + switch name { + case servers.FieldUserid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserid(v) + return nil + case servers.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case servers.FieldIsOwner: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsOwner(v) + return nil + case servers.FieldPermission: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermission(v) + return nil + } + return fmt.Errorf("unknown Servers field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *ServersMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *ServersMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *ServersMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Servers numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *ServersMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *ServersMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *ServersMutation) ClearField(name string) error { + return fmt.Errorf("unknown Servers nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *ServersMutation) ResetField(name string) error { + switch name { + case servers.FieldUserid: + m.ResetUserid() + return nil + case servers.FieldServerid: + m.ResetServerid() + return nil + case servers.FieldIsOwner: + m.ResetIsOwner() + return nil + case servers.FieldPermission: + m.ResetPermission() + return nil + } + return fmt.Errorf("unknown Servers field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *ServersMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *ServersMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *ServersMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *ServersMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *ServersMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *ServersMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *ServersMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Servers unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *ServersMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Servers edge %s", name) +} + +// SettingsMutation represents an operation that mutates the Settings nodes in the graph. +type SettingsMutation struct { + config + op Op + typ string + id *int + serverid *string + servername *string + ownerid *string + permtoken *string + apitoken *string + statspagemode *string + loggerchannel *string + spamchannel *string + greeterchannel *string + greetermode *string + announcechannel *string + logger *bool + spamprotection *bool + linkprotection *bool + wordfilter *bool + greetings *bool + apitoggle *bool + moderation *bool + automatedmoderation *bool + twitchannounce *bool + twitterannounce *bool + music *bool + statspage *bool + statsprivate *bool + stats *bool + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Settings, error) + predicates []predicate.Settings +} + +var _ ent.Mutation = (*SettingsMutation)(nil) + +// settingsOption allows management of the mutation configuration using functional options. +type settingsOption func(*SettingsMutation) + +// newSettingsMutation creates new mutation for the Settings entity. +func newSettingsMutation(c config, op Op, opts ...settingsOption) *SettingsMutation { + m := &SettingsMutation{ + config: c, + op: op, + typ: TypeSettings, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSettingsID sets the ID field of the mutation. +func withSettingsID(id int) settingsOption { + return func(m *SettingsMutation) { + var ( + err error + once sync.Once + value *Settings + ) + m.oldValue = func(ctx context.Context) (*Settings, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Settings.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSettings sets the old Settings of the mutation. +func withSettings(node *Settings) settingsOption { + return func(m *SettingsMutation) { + m.oldValue = func(context.Context) (*Settings, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SettingsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SettingsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Settings entities. +func (m *SettingsMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SettingsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SettingsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Settings.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *SettingsMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *SettingsMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *SettingsMutation) ResetServerid() { + m.serverid = nil +} + +// SetServername sets the "servername" field. +func (m *SettingsMutation) SetServername(s string) { + m.servername = &s +} + +// Servername returns the value of the "servername" field in the mutation. +func (m *SettingsMutation) Servername() (r string, exists bool) { + v := m.servername + if v == nil { + return + } + return *v, true +} + +// OldServername returns the old "servername" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldServername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServername: %w", err) + } + return oldValue.Servername, nil +} + +// ResetServername resets all changes to the "servername" field. +func (m *SettingsMutation) ResetServername() { + m.servername = nil +} + +// SetOwnerid sets the "ownerid" field. +func (m *SettingsMutation) SetOwnerid(s string) { + m.ownerid = &s +} + +// Ownerid returns the value of the "ownerid" field in the mutation. +func (m *SettingsMutation) Ownerid() (r string, exists bool) { + v := m.ownerid + if v == nil { + return + } + return *v, true +} + +// OldOwnerid returns the old "ownerid" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldOwnerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldOwnerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldOwnerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldOwnerid: %w", err) + } + return oldValue.Ownerid, nil +} + +// ResetOwnerid resets all changes to the "ownerid" field. +func (m *SettingsMutation) ResetOwnerid() { + m.ownerid = nil +} + +// SetPermtoken sets the "permtoken" field. +func (m *SettingsMutation) SetPermtoken(s string) { + m.permtoken = &s +} + +// Permtoken returns the value of the "permtoken" field in the mutation. +func (m *SettingsMutation) Permtoken() (r string, exists bool) { + v := m.permtoken + if v == nil { + return + } + return *v, true +} + +// OldPermtoken returns the old "permtoken" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldPermtoken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldPermtoken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldPermtoken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldPermtoken: %w", err) + } + return oldValue.Permtoken, nil +} + +// ResetPermtoken resets all changes to the "permtoken" field. +func (m *SettingsMutation) ResetPermtoken() { + m.permtoken = nil +} + +// SetApitoken sets the "apitoken" field. +func (m *SettingsMutation) SetApitoken(s string) { + m.apitoken = &s +} + +// Apitoken returns the value of the "apitoken" field in the mutation. +func (m *SettingsMutation) Apitoken() (r string, exists bool) { + v := m.apitoken + if v == nil { + return + } + return *v, true +} + +// OldApitoken returns the old "apitoken" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldApitoken(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldApitoken is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldApitoken requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldApitoken: %w", err) + } + return oldValue.Apitoken, nil +} + +// ResetApitoken resets all changes to the "apitoken" field. +func (m *SettingsMutation) ResetApitoken() { + m.apitoken = nil +} + +// SetStatspagemode sets the "statspagemode" field. +func (m *SettingsMutation) SetStatspagemode(s string) { + m.statspagemode = &s +} + +// Statspagemode returns the value of the "statspagemode" field in the mutation. +func (m *SettingsMutation) Statspagemode() (r string, exists bool) { + v := m.statspagemode + if v == nil { + return + } + return *v, true +} + +// OldStatspagemode returns the old "statspagemode" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldStatspagemode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatspagemode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatspagemode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatspagemode: %w", err) + } + return oldValue.Statspagemode, nil +} + +// ResetStatspagemode resets all changes to the "statspagemode" field. +func (m *SettingsMutation) ResetStatspagemode() { + m.statspagemode = nil +} + +// SetLoggerchannel sets the "loggerchannel" field. +func (m *SettingsMutation) SetLoggerchannel(s string) { + m.loggerchannel = &s +} + +// Loggerchannel returns the value of the "loggerchannel" field in the mutation. +func (m *SettingsMutation) Loggerchannel() (r string, exists bool) { + v := m.loggerchannel + if v == nil { + return + } + return *v, true +} + +// OldLoggerchannel returns the old "loggerchannel" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldLoggerchannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLoggerchannel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLoggerchannel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLoggerchannel: %w", err) + } + return oldValue.Loggerchannel, nil +} + +// ResetLoggerchannel resets all changes to the "loggerchannel" field. +func (m *SettingsMutation) ResetLoggerchannel() { + m.loggerchannel = nil +} + +// SetSpamchannel sets the "spamchannel" field. +func (m *SettingsMutation) SetSpamchannel(s string) { + m.spamchannel = &s +} + +// Spamchannel returns the value of the "spamchannel" field in the mutation. +func (m *SettingsMutation) Spamchannel() (r string, exists bool) { + v := m.spamchannel + if v == nil { + return + } + return *v, true +} + +// OldSpamchannel returns the old "spamchannel" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldSpamchannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSpamchannel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSpamchannel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSpamchannel: %w", err) + } + return oldValue.Spamchannel, nil +} + +// ResetSpamchannel resets all changes to the "spamchannel" field. +func (m *SettingsMutation) ResetSpamchannel() { + m.spamchannel = nil +} + +// SetGreeterchannel sets the "greeterchannel" field. +func (m *SettingsMutation) SetGreeterchannel(s string) { + m.greeterchannel = &s +} + +// Greeterchannel returns the value of the "greeterchannel" field in the mutation. +func (m *SettingsMutation) Greeterchannel() (r string, exists bool) { + v := m.greeterchannel + if v == nil { + return + } + return *v, true +} + +// OldGreeterchannel returns the old "greeterchannel" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldGreeterchannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGreeterchannel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGreeterchannel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGreeterchannel: %w", err) + } + return oldValue.Greeterchannel, nil +} + +// ResetGreeterchannel resets all changes to the "greeterchannel" field. +func (m *SettingsMutation) ResetGreeterchannel() { + m.greeterchannel = nil +} + +// SetGreetermode sets the "greetermode" field. +func (m *SettingsMutation) SetGreetermode(s string) { + m.greetermode = &s +} + +// Greetermode returns the value of the "greetermode" field in the mutation. +func (m *SettingsMutation) Greetermode() (r string, exists bool) { + v := m.greetermode + if v == nil { + return + } + return *v, true +} + +// OldGreetermode returns the old "greetermode" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldGreetermode(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGreetermode is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGreetermode requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGreetermode: %w", err) + } + return oldValue.Greetermode, nil +} + +// ResetGreetermode resets all changes to the "greetermode" field. +func (m *SettingsMutation) ResetGreetermode() { + m.greetermode = nil +} + +// SetAnnouncechannel sets the "announcechannel" field. +func (m *SettingsMutation) SetAnnouncechannel(s string) { + m.announcechannel = &s +} + +// Announcechannel returns the value of the "announcechannel" field in the mutation. +func (m *SettingsMutation) Announcechannel() (r string, exists bool) { + v := m.announcechannel + if v == nil { + return + } + return *v, true +} + +// OldAnnouncechannel returns the old "announcechannel" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldAnnouncechannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAnnouncechannel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAnnouncechannel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAnnouncechannel: %w", err) + } + return oldValue.Announcechannel, nil +} + +// ResetAnnouncechannel resets all changes to the "announcechannel" field. +func (m *SettingsMutation) ResetAnnouncechannel() { + m.announcechannel = nil +} + +// SetLogger sets the "logger" field. +func (m *SettingsMutation) SetLogger(b bool) { + m.logger = &b +} + +// Logger returns the value of the "logger" field in the mutation. +func (m *SettingsMutation) Logger() (r bool, exists bool) { + v := m.logger + if v == nil { + return + } + return *v, true +} + +// OldLogger returns the old "logger" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldLogger(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLogger is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLogger requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLogger: %w", err) + } + return oldValue.Logger, nil +} + +// ResetLogger resets all changes to the "logger" field. +func (m *SettingsMutation) ResetLogger() { + m.logger = nil +} + +// SetSpamprotection sets the "spamprotection" field. +func (m *SettingsMutation) SetSpamprotection(b bool) { + m.spamprotection = &b +} + +// Spamprotection returns the value of the "spamprotection" field in the mutation. +func (m *SettingsMutation) Spamprotection() (r bool, exists bool) { + v := m.spamprotection + if v == nil { + return + } + return *v, true +} + +// OldSpamprotection returns the old "spamprotection" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldSpamprotection(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldSpamprotection is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldSpamprotection requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldSpamprotection: %w", err) + } + return oldValue.Spamprotection, nil +} + +// ResetSpamprotection resets all changes to the "spamprotection" field. +func (m *SettingsMutation) ResetSpamprotection() { + m.spamprotection = nil +} + +// SetLinkprotection sets the "linkprotection" field. +func (m *SettingsMutation) SetLinkprotection(b bool) { + m.linkprotection = &b +} + +// Linkprotection returns the value of the "linkprotection" field in the mutation. +func (m *SettingsMutation) Linkprotection() (r bool, exists bool) { + v := m.linkprotection + if v == nil { + return + } + return *v, true +} + +// OldLinkprotection returns the old "linkprotection" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldLinkprotection(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLinkprotection is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLinkprotection requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLinkprotection: %w", err) + } + return oldValue.Linkprotection, nil +} + +// ResetLinkprotection resets all changes to the "linkprotection" field. +func (m *SettingsMutation) ResetLinkprotection() { + m.linkprotection = nil +} + +// SetWordfilter sets the "wordfilter" field. +func (m *SettingsMutation) SetWordfilter(b bool) { + m.wordfilter = &b +} + +// Wordfilter returns the value of the "wordfilter" field in the mutation. +func (m *SettingsMutation) Wordfilter() (r bool, exists bool) { + v := m.wordfilter + if v == nil { + return + } + return *v, true +} + +// OldWordfilter returns the old "wordfilter" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldWordfilter(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWordfilter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWordfilter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWordfilter: %w", err) + } + return oldValue.Wordfilter, nil +} + +// ResetWordfilter resets all changes to the "wordfilter" field. +func (m *SettingsMutation) ResetWordfilter() { + m.wordfilter = nil +} + +// SetGreetings sets the "greetings" field. +func (m *SettingsMutation) SetGreetings(b bool) { + m.greetings = &b +} + +// Greetings returns the value of the "greetings" field in the mutation. +func (m *SettingsMutation) Greetings() (r bool, exists bool) { + v := m.greetings + if v == nil { + return + } + return *v, true +} + +// OldGreetings returns the old "greetings" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldGreetings(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldGreetings is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldGreetings requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldGreetings: %w", err) + } + return oldValue.Greetings, nil +} + +// ResetGreetings resets all changes to the "greetings" field. +func (m *SettingsMutation) ResetGreetings() { + m.greetings = nil +} + +// SetApitoggle sets the "apitoggle" field. +func (m *SettingsMutation) SetApitoggle(b bool) { + m.apitoggle = &b +} + +// Apitoggle returns the value of the "apitoggle" field in the mutation. +func (m *SettingsMutation) Apitoggle() (r bool, exists bool) { + v := m.apitoggle + if v == nil { + return + } + return *v, true +} + +// OldApitoggle returns the old "apitoggle" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldApitoggle(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldApitoggle is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldApitoggle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldApitoggle: %w", err) + } + return oldValue.Apitoggle, nil +} + +// ResetApitoggle resets all changes to the "apitoggle" field. +func (m *SettingsMutation) ResetApitoggle() { + m.apitoggle = nil +} + +// SetModeration sets the "moderation" field. +func (m *SettingsMutation) SetModeration(b bool) { + m.moderation = &b +} + +// Moderation returns the value of the "moderation" field in the mutation. +func (m *SettingsMutation) Moderation() (r bool, exists bool) { + v := m.moderation + if v == nil { + return + } + return *v, true +} + +// OldModeration returns the old "moderation" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldModeration(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldModeration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldModeration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldModeration: %w", err) + } + return oldValue.Moderation, nil +} + +// ResetModeration resets all changes to the "moderation" field. +func (m *SettingsMutation) ResetModeration() { + m.moderation = nil +} + +// SetAutomatedmoderation sets the "automatedmoderation" field. +func (m *SettingsMutation) SetAutomatedmoderation(b bool) { + m.automatedmoderation = &b +} + +// Automatedmoderation returns the value of the "automatedmoderation" field in the mutation. +func (m *SettingsMutation) Automatedmoderation() (r bool, exists bool) { + v := m.automatedmoderation + if v == nil { + return + } + return *v, true +} + +// OldAutomatedmoderation returns the old "automatedmoderation" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldAutomatedmoderation(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldAutomatedmoderation is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldAutomatedmoderation requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldAutomatedmoderation: %w", err) + } + return oldValue.Automatedmoderation, nil +} + +// ResetAutomatedmoderation resets all changes to the "automatedmoderation" field. +func (m *SettingsMutation) ResetAutomatedmoderation() { + m.automatedmoderation = nil +} + +// SetTwitchannounce sets the "twitchannounce" field. +func (m *SettingsMutation) SetTwitchannounce(b bool) { + m.twitchannounce = &b +} + +// Twitchannounce returns the value of the "twitchannounce" field in the mutation. +func (m *SettingsMutation) Twitchannounce() (r bool, exists bool) { + v := m.twitchannounce + if v == nil { + return + } + return *v, true +} + +// OldTwitchannounce returns the old "twitchannounce" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldTwitchannounce(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTwitchannounce is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTwitchannounce requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTwitchannounce: %w", err) + } + return oldValue.Twitchannounce, nil +} + +// ResetTwitchannounce resets all changes to the "twitchannounce" field. +func (m *SettingsMutation) ResetTwitchannounce() { + m.twitchannounce = nil +} + +// SetTwitterannounce sets the "twitterannounce" field. +func (m *SettingsMutation) SetTwitterannounce(b bool) { + m.twitterannounce = &b +} + +// Twitterannounce returns the value of the "twitterannounce" field in the mutation. +func (m *SettingsMutation) Twitterannounce() (r bool, exists bool) { + v := m.twitterannounce + if v == nil { + return + } + return *v, true +} + +// OldTwitterannounce returns the old "twitterannounce" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldTwitterannounce(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTwitterannounce is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTwitterannounce requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTwitterannounce: %w", err) + } + return oldValue.Twitterannounce, nil +} + +// ResetTwitterannounce resets all changes to the "twitterannounce" field. +func (m *SettingsMutation) ResetTwitterannounce() { + m.twitterannounce = nil +} + +// SetMusic sets the "music" field. +func (m *SettingsMutation) SetMusic(b bool) { + m.music = &b +} + +// Music returns the value of the "music" field in the mutation. +func (m *SettingsMutation) Music() (r bool, exists bool) { + v := m.music + if v == nil { + return + } + return *v, true +} + +// OldMusic returns the old "music" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldMusic(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMusic is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMusic requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMusic: %w", err) + } + return oldValue.Music, nil +} + +// ResetMusic resets all changes to the "music" field. +func (m *SettingsMutation) ResetMusic() { + m.music = nil +} + +// SetStatspage sets the "statspage" field. +func (m *SettingsMutation) SetStatspage(b bool) { + m.statspage = &b +} + +// Statspage returns the value of the "statspage" field in the mutation. +func (m *SettingsMutation) Statspage() (r bool, exists bool) { + v := m.statspage + if v == nil { + return + } + return *v, true +} + +// OldStatspage returns the old "statspage" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldStatspage(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatspage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatspage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatspage: %w", err) + } + return oldValue.Statspage, nil +} + +// ResetStatspage resets all changes to the "statspage" field. +func (m *SettingsMutation) ResetStatspage() { + m.statspage = nil +} + +// SetStatsprivate sets the "statsprivate" field. +func (m *SettingsMutation) SetStatsprivate(b bool) { + m.statsprivate = &b +} + +// Statsprivate returns the value of the "statsprivate" field in the mutation. +func (m *SettingsMutation) Statsprivate() (r bool, exists bool) { + v := m.statsprivate + if v == nil { + return + } + return *v, true +} + +// OldStatsprivate returns the old "statsprivate" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldStatsprivate(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatsprivate is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatsprivate requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatsprivate: %w", err) + } + return oldValue.Statsprivate, nil +} + +// ResetStatsprivate resets all changes to the "statsprivate" field. +func (m *SettingsMutation) ResetStatsprivate() { + m.statsprivate = nil +} + +// SetStats sets the "stats" field. +func (m *SettingsMutation) SetStats(b bool) { + m.stats = &b +} + +// Stats returns the value of the "stats" field in the mutation. +func (m *SettingsMutation) Stats() (r bool, exists bool) { + v := m.stats + if v == nil { + return + } + return *v, true +} + +// OldStats returns the old "stats" field's value of the Settings entity. +// If the Settings object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SettingsMutation) OldStats(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStats is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStats requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStats: %w", err) + } + return oldValue.Stats, nil +} + +// ResetStats resets all changes to the "stats" field. +func (m *SettingsMutation) ResetStats() { + m.stats = nil +} + +// Where appends a list predicates to the SettingsMutation builder. +func (m *SettingsMutation) Where(ps ...predicate.Settings) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *SettingsMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Settings). +func (m *SettingsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SettingsMutation) Fields() []string { + fields := make([]string, 0, 25) + if m.serverid != nil { + fields = append(fields, settings.FieldServerid) + } + if m.servername != nil { + fields = append(fields, settings.FieldServername) + } + if m.ownerid != nil { + fields = append(fields, settings.FieldOwnerid) + } + if m.permtoken != nil { + fields = append(fields, settings.FieldPermtoken) + } + if m.apitoken != nil { + fields = append(fields, settings.FieldApitoken) + } + if m.statspagemode != nil { + fields = append(fields, settings.FieldStatspagemode) + } + if m.loggerchannel != nil { + fields = append(fields, settings.FieldLoggerchannel) + } + if m.spamchannel != nil { + fields = append(fields, settings.FieldSpamchannel) + } + if m.greeterchannel != nil { + fields = append(fields, settings.FieldGreeterchannel) + } + if m.greetermode != nil { + fields = append(fields, settings.FieldGreetermode) + } + if m.announcechannel != nil { + fields = append(fields, settings.FieldAnnouncechannel) + } + if m.logger != nil { + fields = append(fields, settings.FieldLogger) + } + if m.spamprotection != nil { + fields = append(fields, settings.FieldSpamprotection) + } + if m.linkprotection != nil { + fields = append(fields, settings.FieldLinkprotection) + } + if m.wordfilter != nil { + fields = append(fields, settings.FieldWordfilter) + } + if m.greetings != nil { + fields = append(fields, settings.FieldGreetings) + } + if m.apitoggle != nil { + fields = append(fields, settings.FieldApitoggle) + } + if m.moderation != nil { + fields = append(fields, settings.FieldModeration) + } + if m.automatedmoderation != nil { + fields = append(fields, settings.FieldAutomatedmoderation) + } + if m.twitchannounce != nil { + fields = append(fields, settings.FieldTwitchannounce) + } + if m.twitterannounce != nil { + fields = append(fields, settings.FieldTwitterannounce) + } + if m.music != nil { + fields = append(fields, settings.FieldMusic) + } + if m.statspage != nil { + fields = append(fields, settings.FieldStatspage) + } + if m.statsprivate != nil { + fields = append(fields, settings.FieldStatsprivate) + } + if m.stats != nil { + fields = append(fields, settings.FieldStats) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SettingsMutation) Field(name string) (ent.Value, bool) { + switch name { + case settings.FieldServerid: + return m.Serverid() + case settings.FieldServername: + return m.Servername() + case settings.FieldOwnerid: + return m.Ownerid() + case settings.FieldPermtoken: + return m.Permtoken() + case settings.FieldApitoken: + return m.Apitoken() + case settings.FieldStatspagemode: + return m.Statspagemode() + case settings.FieldLoggerchannel: + return m.Loggerchannel() + case settings.FieldSpamchannel: + return m.Spamchannel() + case settings.FieldGreeterchannel: + return m.Greeterchannel() + case settings.FieldGreetermode: + return m.Greetermode() + case settings.FieldAnnouncechannel: + return m.Announcechannel() + case settings.FieldLogger: + return m.Logger() + case settings.FieldSpamprotection: + return m.Spamprotection() + case settings.FieldLinkprotection: + return m.Linkprotection() + case settings.FieldWordfilter: + return m.Wordfilter() + case settings.FieldGreetings: + return m.Greetings() + case settings.FieldApitoggle: + return m.Apitoggle() + case settings.FieldModeration: + return m.Moderation() + case settings.FieldAutomatedmoderation: + return m.Automatedmoderation() + case settings.FieldTwitchannounce: + return m.Twitchannounce() + case settings.FieldTwitterannounce: + return m.Twitterannounce() + case settings.FieldMusic: + return m.Music() + case settings.FieldStatspage: + return m.Statspage() + case settings.FieldStatsprivate: + return m.Statsprivate() + case settings.FieldStats: + return m.Stats() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SettingsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case settings.FieldServerid: + return m.OldServerid(ctx) + case settings.FieldServername: + return m.OldServername(ctx) + case settings.FieldOwnerid: + return m.OldOwnerid(ctx) + case settings.FieldPermtoken: + return m.OldPermtoken(ctx) + case settings.FieldApitoken: + return m.OldApitoken(ctx) + case settings.FieldStatspagemode: + return m.OldStatspagemode(ctx) + case settings.FieldLoggerchannel: + return m.OldLoggerchannel(ctx) + case settings.FieldSpamchannel: + return m.OldSpamchannel(ctx) + case settings.FieldGreeterchannel: + return m.OldGreeterchannel(ctx) + case settings.FieldGreetermode: + return m.OldGreetermode(ctx) + case settings.FieldAnnouncechannel: + return m.OldAnnouncechannel(ctx) + case settings.FieldLogger: + return m.OldLogger(ctx) + case settings.FieldSpamprotection: + return m.OldSpamprotection(ctx) + case settings.FieldLinkprotection: + return m.OldLinkprotection(ctx) + case settings.FieldWordfilter: + return m.OldWordfilter(ctx) + case settings.FieldGreetings: + return m.OldGreetings(ctx) + case settings.FieldApitoggle: + return m.OldApitoggle(ctx) + case settings.FieldModeration: + return m.OldModeration(ctx) + case settings.FieldAutomatedmoderation: + return m.OldAutomatedmoderation(ctx) + case settings.FieldTwitchannounce: + return m.OldTwitchannounce(ctx) + case settings.FieldTwitterannounce: + return m.OldTwitterannounce(ctx) + case settings.FieldMusic: + return m.OldMusic(ctx) + case settings.FieldStatspage: + return m.OldStatspage(ctx) + case settings.FieldStatsprivate: + return m.OldStatsprivate(ctx) + case settings.FieldStats: + return m.OldStats(ctx) + } + return nil, fmt.Errorf("unknown Settings field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SettingsMutation) SetField(name string, value ent.Value) error { + switch name { + case settings.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case settings.FieldServername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServername(v) + return nil + case settings.FieldOwnerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetOwnerid(v) + return nil + case settings.FieldPermtoken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetPermtoken(v) + return nil + case settings.FieldApitoken: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetApitoken(v) + return nil + case settings.FieldStatspagemode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatspagemode(v) + return nil + case settings.FieldLoggerchannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLoggerchannel(v) + return nil + case settings.FieldSpamchannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpamchannel(v) + return nil + case settings.FieldGreeterchannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGreeterchannel(v) + return nil + case settings.FieldGreetermode: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGreetermode(v) + return nil + case settings.FieldAnnouncechannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAnnouncechannel(v) + return nil + case settings.FieldLogger: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLogger(v) + return nil + case settings.FieldSpamprotection: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetSpamprotection(v) + return nil + case settings.FieldLinkprotection: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLinkprotection(v) + return nil + case settings.FieldWordfilter: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWordfilter(v) + return nil + case settings.FieldGreetings: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetGreetings(v) + return nil + case settings.FieldApitoggle: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetApitoggle(v) + return nil + case settings.FieldModeration: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetModeration(v) + return nil + case settings.FieldAutomatedmoderation: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetAutomatedmoderation(v) + return nil + case settings.FieldTwitchannounce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTwitchannounce(v) + return nil + case settings.FieldTwitterannounce: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTwitterannounce(v) + return nil + case settings.FieldMusic: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMusic(v) + return nil + case settings.FieldStatspage: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatspage(v) + return nil + case settings.FieldStatsprivate: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatsprivate(v) + return nil + case settings.FieldStats: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStats(v) + return nil + } + return fmt.Errorf("unknown Settings field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SettingsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SettingsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SettingsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Settings numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SettingsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SettingsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *SettingsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Settings nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *SettingsMutation) ResetField(name string) error { + switch name { + case settings.FieldServerid: + m.ResetServerid() + return nil + case settings.FieldServername: + m.ResetServername() + return nil + case settings.FieldOwnerid: + m.ResetOwnerid() + return nil + case settings.FieldPermtoken: + m.ResetPermtoken() + return nil + case settings.FieldApitoken: + m.ResetApitoken() + return nil + case settings.FieldStatspagemode: + m.ResetStatspagemode() + return nil + case settings.FieldLoggerchannel: + m.ResetLoggerchannel() + return nil + case settings.FieldSpamchannel: + m.ResetSpamchannel() + return nil + case settings.FieldGreeterchannel: + m.ResetGreeterchannel() + return nil + case settings.FieldGreetermode: + m.ResetGreetermode() + return nil + case settings.FieldAnnouncechannel: + m.ResetAnnouncechannel() + return nil + case settings.FieldLogger: + m.ResetLogger() + return nil + case settings.FieldSpamprotection: + m.ResetSpamprotection() + return nil + case settings.FieldLinkprotection: + m.ResetLinkprotection() + return nil + case settings.FieldWordfilter: + m.ResetWordfilter() + return nil + case settings.FieldGreetings: + m.ResetGreetings() + return nil + case settings.FieldApitoggle: + m.ResetApitoggle() + return nil + case settings.FieldModeration: + m.ResetModeration() + return nil + case settings.FieldAutomatedmoderation: + m.ResetAutomatedmoderation() + return nil + case settings.FieldTwitchannounce: + m.ResetTwitchannounce() + return nil + case settings.FieldTwitterannounce: + m.ResetTwitterannounce() + return nil + case settings.FieldMusic: + m.ResetMusic() + return nil + case settings.FieldStatspage: + m.ResetStatspage() + return nil + case settings.FieldStatsprivate: + m.ResetStatsprivate() + return nil + case settings.FieldStats: + m.ResetStats() + return nil + } + return fmt.Errorf("unknown Settings field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SettingsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SettingsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SettingsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SettingsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SettingsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SettingsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *SettingsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Settings unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *SettingsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Settings edge %s", name) +} + +// SocialmediaMutation represents an operation that mutates the Socialmedia nodes in the graph. +type SocialmediaMutation struct { + config + op Op + typ string + id *int + serverid *string + _type *string + identificator *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Socialmedia, error) + predicates []predicate.Socialmedia +} + +var _ ent.Mutation = (*SocialmediaMutation)(nil) + +// socialmediaOption allows management of the mutation configuration using functional options. +type socialmediaOption func(*SocialmediaMutation) + +// newSocialmediaMutation creates new mutation for the Socialmedia entity. +func newSocialmediaMutation(c config, op Op, opts ...socialmediaOption) *SocialmediaMutation { + m := &SocialmediaMutation{ + config: c, + op: op, + typ: TypeSocialmedia, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSocialmediaID sets the ID field of the mutation. +func withSocialmediaID(id int) socialmediaOption { + return func(m *SocialmediaMutation) { + var ( + err error + once sync.Once + value *Socialmedia + ) + m.oldValue = func(ctx context.Context) (*Socialmedia, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Socialmedia.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSocialmedia sets the old Socialmedia of the mutation. +func withSocialmedia(node *Socialmedia) socialmediaOption { + return func(m *SocialmediaMutation) { + m.oldValue = func(context.Context) (*Socialmedia, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SocialmediaMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SocialmediaMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Socialmedia entities. +func (m *SocialmediaMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SocialmediaMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SocialmediaMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Socialmedia.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *SocialmediaMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *SocialmediaMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Socialmedia entity. +// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SocialmediaMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *SocialmediaMutation) ResetServerid() { + m.serverid = nil +} + +// SetType sets the "type" field. +func (m *SocialmediaMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *SocialmediaMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Socialmedia entity. +// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SocialmediaMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *SocialmediaMutation) ResetType() { + m._type = nil +} + +// SetIdentificator sets the "identificator" field. +func (m *SocialmediaMutation) SetIdentificator(s string) { + m.identificator = &s +} + +// Identificator returns the value of the "identificator" field in the mutation. +func (m *SocialmediaMutation) Identificator() (r string, exists bool) { + v := m.identificator + if v == nil { + return + } + return *v, true +} + +// OldIdentificator returns the old "identificator" field's value of the Socialmedia entity. +// If the Socialmedia object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SocialmediaMutation) OldIdentificator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIdentificator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIdentificator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIdentificator: %w", err) + } + return oldValue.Identificator, nil +} + +// ResetIdentificator resets all changes to the "identificator" field. +func (m *SocialmediaMutation) ResetIdentificator() { + m.identificator = nil +} + +// Where appends a list predicates to the SocialmediaMutation builder. +func (m *SocialmediaMutation) Where(ps ...predicate.Socialmedia) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *SocialmediaMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Socialmedia). +func (m *SocialmediaMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SocialmediaMutation) Fields() []string { + fields := make([]string, 0, 3) + if m.serverid != nil { + fields = append(fields, socialmedia.FieldServerid) + } + if m._type != nil { + fields = append(fields, socialmedia.FieldType) + } + if m.identificator != nil { + fields = append(fields, socialmedia.FieldIdentificator) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SocialmediaMutation) Field(name string) (ent.Value, bool) { + switch name { + case socialmedia.FieldServerid: + return m.Serverid() + case socialmedia.FieldType: + return m.GetType() + case socialmedia.FieldIdentificator: + return m.Identificator() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SocialmediaMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case socialmedia.FieldServerid: + return m.OldServerid(ctx) + case socialmedia.FieldType: + return m.OldType(ctx) + case socialmedia.FieldIdentificator: + return m.OldIdentificator(ctx) + } + return nil, fmt.Errorf("unknown Socialmedia field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SocialmediaMutation) SetField(name string, value ent.Value) error { + switch name { + case socialmedia.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case socialmedia.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case socialmedia.FieldIdentificator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIdentificator(v) + return nil + } + return fmt.Errorf("unknown Socialmedia field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SocialmediaMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SocialmediaMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SocialmediaMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Socialmedia numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SocialmediaMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SocialmediaMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *SocialmediaMutation) ClearField(name string) error { + return fmt.Errorf("unknown Socialmedia nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *SocialmediaMutation) ResetField(name string) error { + switch name { + case socialmedia.FieldServerid: + m.ResetServerid() + return nil + case socialmedia.FieldType: + m.ResetType() + return nil + case socialmedia.FieldIdentificator: + m.ResetIdentificator() + return nil + } + return fmt.Errorf("unknown Socialmedia field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SocialmediaMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SocialmediaMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SocialmediaMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SocialmediaMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SocialmediaMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SocialmediaMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *SocialmediaMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Socialmedia unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *SocialmediaMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Socialmedia edge %s", name) +} + +// SupportMutation represents an operation that mutates the Support nodes in the graph. +type SupportMutation struct { + config + op Op + typ string + id *int + refid *string + serverid *string + creator *string + status *string + title *string + description *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Support, error) + predicates []predicate.Support +} + +var _ ent.Mutation = (*SupportMutation)(nil) + +// supportOption allows management of the mutation configuration using functional options. +type supportOption func(*SupportMutation) + +// newSupportMutation creates new mutation for the Support entity. +func newSupportMutation(c config, op Op, opts ...supportOption) *SupportMutation { + m := &SupportMutation{ + config: c, + op: op, + typ: TypeSupport, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSupportID sets the ID field of the mutation. +func withSupportID(id int) supportOption { + return func(m *SupportMutation) { + var ( + err error + once sync.Once + value *Support + ) + m.oldValue = func(ctx context.Context) (*Support, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Support.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSupport sets the old Support of the mutation. +func withSupport(node *Support) supportOption { + return func(m *SupportMutation) { + m.oldValue = func(context.Context) (*Support, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SupportMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SupportMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Support entities. +func (m *SupportMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SupportMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SupportMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Support.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRefid sets the "refid" field. +func (m *SupportMutation) SetRefid(s string) { + m.refid = &s +} + +// Refid returns the value of the "refid" field in the mutation. +func (m *SupportMutation) Refid() (r string, exists bool) { + v := m.refid + if v == nil { + return + } + return *v, true +} + +// OldRefid returns the old "refid" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldRefid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefid: %w", err) + } + return oldValue.Refid, nil +} + +// ResetRefid resets all changes to the "refid" field. +func (m *SupportMutation) ResetRefid() { + m.refid = nil +} + +// SetServerid sets the "serverid" field. +func (m *SupportMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *SupportMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *SupportMutation) ResetServerid() { + m.serverid = nil +} + +// SetCreator sets the "creator" field. +func (m *SupportMutation) SetCreator(s string) { + m.creator = &s +} + +// Creator returns the value of the "creator" field in the mutation. +func (m *SupportMutation) Creator() (r string, exists bool) { + v := m.creator + if v == nil { + return + } + return *v, true +} + +// OldCreator returns the old "creator" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldCreator(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreator is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreator requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreator: %w", err) + } + return oldValue.Creator, nil +} + +// ResetCreator resets all changes to the "creator" field. +func (m *SupportMutation) ResetCreator() { + m.creator = nil +} + +// SetStatus sets the "status" field. +func (m *SupportMutation) SetStatus(s string) { + m.status = &s +} + +// Status returns the value of the "status" field in the mutation. +func (m *SupportMutation) Status() (r string, exists bool) { + v := m.status + if v == nil { + return + } + return *v, true +} + +// OldStatus returns the old "status" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldStatus(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldStatus is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldStatus requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldStatus: %w", err) + } + return oldValue.Status, nil +} + +// ResetStatus resets all changes to the "status" field. +func (m *SupportMutation) ResetStatus() { + m.status = nil +} + +// SetTitle sets the "title" field. +func (m *SupportMutation) SetTitle(s string) { + m.title = &s +} + +// Title returns the value of the "title" field in the mutation. +func (m *SupportMutation) Title() (r string, exists bool) { + v := m.title + if v == nil { + return + } + return *v, true +} + +// OldTitle returns the old "title" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldTitle(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTitle is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTitle requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTitle: %w", err) + } + return oldValue.Title, nil +} + +// ResetTitle resets all changes to the "title" field. +func (m *SupportMutation) ResetTitle() { + m.title = nil +} + +// SetDescription sets the "description" field. +func (m *SupportMutation) SetDescription(s string) { + m.description = &s +} + +// Description returns the value of the "description" field in the mutation. +func (m *SupportMutation) Description() (r string, exists bool) { + v := m.description + if v == nil { + return + } + return *v, true +} + +// OldDescription returns the old "description" field's value of the Support entity. +// If the Support object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportMutation) OldDescription(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDescription is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDescription requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDescription: %w", err) + } + return oldValue.Description, nil +} + +// ResetDescription resets all changes to the "description" field. +func (m *SupportMutation) ResetDescription() { + m.description = nil +} + +// Where appends a list predicates to the SupportMutation builder. +func (m *SupportMutation) Where(ps ...predicate.Support) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *SupportMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Support). +func (m *SupportMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SupportMutation) Fields() []string { + fields := make([]string, 0, 6) + if m.refid != nil { + fields = append(fields, support.FieldRefid) + } + if m.serverid != nil { + fields = append(fields, support.FieldServerid) + } + if m.creator != nil { + fields = append(fields, support.FieldCreator) + } + if m.status != nil { + fields = append(fields, support.FieldStatus) + } + if m.title != nil { + fields = append(fields, support.FieldTitle) + } + if m.description != nil { + fields = append(fields, support.FieldDescription) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SupportMutation) Field(name string) (ent.Value, bool) { + switch name { + case support.FieldRefid: + return m.Refid() + case support.FieldServerid: + return m.Serverid() + case support.FieldCreator: + return m.Creator() + case support.FieldStatus: + return m.Status() + case support.FieldTitle: + return m.Title() + case support.FieldDescription: + return m.Description() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SupportMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case support.FieldRefid: + return m.OldRefid(ctx) + case support.FieldServerid: + return m.OldServerid(ctx) + case support.FieldCreator: + return m.OldCreator(ctx) + case support.FieldStatus: + return m.OldStatus(ctx) + case support.FieldTitle: + return m.OldTitle(ctx) + case support.FieldDescription: + return m.OldDescription(ctx) + } + return nil, fmt.Errorf("unknown Support field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SupportMutation) SetField(name string, value ent.Value) error { + switch name { + case support.FieldRefid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefid(v) + return nil + case support.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case support.FieldCreator: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreator(v) + return nil + case support.FieldStatus: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetStatus(v) + return nil + case support.FieldTitle: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTitle(v) + return nil + case support.FieldDescription: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDescription(v) + return nil + } + return fmt.Errorf("unknown Support field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SupportMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SupportMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SupportMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Support numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SupportMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SupportMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *SupportMutation) ClearField(name string) error { + return fmt.Errorf("unknown Support nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *SupportMutation) ResetField(name string) error { + switch name { + case support.FieldRefid: + m.ResetRefid() + return nil + case support.FieldServerid: + m.ResetServerid() + return nil + case support.FieldCreator: + m.ResetCreator() + return nil + case support.FieldStatus: + m.ResetStatus() + return nil + case support.FieldTitle: + m.ResetTitle() + return nil + case support.FieldDescription: + m.ResetDescription() + return nil + } + return fmt.Errorf("unknown Support field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SupportMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SupportMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SupportMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SupportMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SupportMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SupportMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *SupportMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Support unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *SupportMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Support edge %s", name) +} + +// SupportResponseMutation represents an operation that mutates the SupportResponse nodes in the graph. +type SupportResponseMutation struct { + config + op Op + typ string + id *int + refid *string + writer *string + message *string + _type *string + rtcchannel *string + isread *bool + created *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*SupportResponse, error) + predicates []predicate.SupportResponse +} + +var _ ent.Mutation = (*SupportResponseMutation)(nil) + +// supportresponseOption allows management of the mutation configuration using functional options. +type supportresponseOption func(*SupportResponseMutation) + +// newSupportResponseMutation creates new mutation for the SupportResponse entity. +func newSupportResponseMutation(c config, op Op, opts ...supportresponseOption) *SupportResponseMutation { + m := &SupportResponseMutation{ + config: c, + op: op, + typ: TypeSupportResponse, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withSupportResponseID sets the ID field of the mutation. +func withSupportResponseID(id int) supportresponseOption { + return func(m *SupportResponseMutation) { + var ( + err error + once sync.Once + value *SupportResponse + ) + m.oldValue = func(ctx context.Context) (*SupportResponse, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().SupportResponse.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withSupportResponse sets the old SupportResponse of the mutation. +func withSupportResponse(node *SupportResponse) supportresponseOption { + return func(m *SupportResponseMutation) { + m.oldValue = func(context.Context) (*SupportResponse, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m SupportResponseMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m SupportResponseMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of SupportResponse entities. +func (m *SupportResponseMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *SupportResponseMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *SupportResponseMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().SupportResponse.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetRefid sets the "refid" field. +func (m *SupportResponseMutation) SetRefid(s string) { + m.refid = &s +} + +// Refid returns the value of the "refid" field in the mutation. +func (m *SupportResponseMutation) Refid() (r string, exists bool) { + v := m.refid + if v == nil { + return + } + return *v, true +} + +// OldRefid returns the old "refid" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldRefid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefid: %w", err) + } + return oldValue.Refid, nil +} + +// ResetRefid resets all changes to the "refid" field. +func (m *SupportResponseMutation) ResetRefid() { + m.refid = nil +} + +// SetWriter sets the "writer" field. +func (m *SupportResponseMutation) SetWriter(s string) { + m.writer = &s +} + +// Writer returns the value of the "writer" field in the mutation. +func (m *SupportResponseMutation) Writer() (r string, exists bool) { + v := m.writer + if v == nil { + return + } + return *v, true +} + +// OldWriter returns the old "writer" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldWriter(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWriter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWriter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWriter: %w", err) + } + return oldValue.Writer, nil +} + +// ResetWriter resets all changes to the "writer" field. +func (m *SupportResponseMutation) ResetWriter() { + m.writer = nil +} + +// SetMessage sets the "message" field. +func (m *SupportResponseMutation) SetMessage(s string) { + m.message = &s +} + +// Message returns the value of the "message" field in the mutation. +func (m *SupportResponseMutation) Message() (r string, exists bool) { + v := m.message + if v == nil { + return + } + return *v, true +} + +// OldMessage returns the old "message" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldMessage(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMessage is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMessage requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMessage: %w", err) + } + return oldValue.Message, nil +} + +// ResetMessage resets all changes to the "message" field. +func (m *SupportResponseMutation) ResetMessage() { + m.message = nil +} + +// SetType sets the "type" field. +func (m *SupportResponseMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *SupportResponseMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *SupportResponseMutation) ResetType() { + m._type = nil +} + +// SetRtcchannel sets the "rtcchannel" field. +func (m *SupportResponseMutation) SetRtcchannel(s string) { + m.rtcchannel = &s +} + +// Rtcchannel returns the value of the "rtcchannel" field in the mutation. +func (m *SupportResponseMutation) Rtcchannel() (r string, exists bool) { + v := m.rtcchannel + if v == nil { + return + } + return *v, true +} + +// OldRtcchannel returns the old "rtcchannel" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldRtcchannel(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRtcchannel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRtcchannel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRtcchannel: %w", err) + } + return oldValue.Rtcchannel, nil +} + +// ResetRtcchannel resets all changes to the "rtcchannel" field. +func (m *SupportResponseMutation) ResetRtcchannel() { + m.rtcchannel = nil +} + +// SetIsread sets the "isread" field. +func (m *SupportResponseMutation) SetIsread(b bool) { + m.isread = &b +} + +// Isread returns the value of the "isread" field in the mutation. +func (m *SupportResponseMutation) Isread() (r bool, exists bool) { + v := m.isread + if v == nil { + return + } + return *v, true +} + +// OldIsread returns the old "isread" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldIsread(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsread is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsread requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsread: %w", err) + } + return oldValue.Isread, nil +} + +// ResetIsread resets all changes to the "isread" field. +func (m *SupportResponseMutation) ResetIsread() { + m.isread = nil +} + +// SetCreated sets the "created" field. +func (m *SupportResponseMutation) SetCreated(t time.Time) { + m.created = &t +} + +// Created returns the value of the "created" field in the mutation. +func (m *SupportResponseMutation) Created() (r time.Time, exists bool) { + v := m.created + if v == nil { + return + } + return *v, true +} + +// OldCreated returns the old "created" field's value of the SupportResponse entity. +// If the SupportResponse object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *SupportResponseMutation) OldCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreated is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreated: %w", err) + } + return oldValue.Created, nil +} + +// ResetCreated resets all changes to the "created" field. +func (m *SupportResponseMutation) ResetCreated() { + m.created = nil +} + +// Where appends a list predicates to the SupportResponseMutation builder. +func (m *SupportResponseMutation) Where(ps ...predicate.SupportResponse) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *SupportResponseMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (SupportResponse). +func (m *SupportResponseMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *SupportResponseMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.refid != nil { + fields = append(fields, supportresponse.FieldRefid) + } + if m.writer != nil { + fields = append(fields, supportresponse.FieldWriter) + } + if m.message != nil { + fields = append(fields, supportresponse.FieldMessage) + } + if m._type != nil { + fields = append(fields, supportresponse.FieldType) + } + if m.rtcchannel != nil { + fields = append(fields, supportresponse.FieldRtcchannel) + } + if m.isread != nil { + fields = append(fields, supportresponse.FieldIsread) + } + if m.created != nil { + fields = append(fields, supportresponse.FieldCreated) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *SupportResponseMutation) Field(name string) (ent.Value, bool) { + switch name { + case supportresponse.FieldRefid: + return m.Refid() + case supportresponse.FieldWriter: + return m.Writer() + case supportresponse.FieldMessage: + return m.Message() + case supportresponse.FieldType: + return m.GetType() + case supportresponse.FieldRtcchannel: + return m.Rtcchannel() + case supportresponse.FieldIsread: + return m.Isread() + case supportresponse.FieldCreated: + return m.Created() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *SupportResponseMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case supportresponse.FieldRefid: + return m.OldRefid(ctx) + case supportresponse.FieldWriter: + return m.OldWriter(ctx) + case supportresponse.FieldMessage: + return m.OldMessage(ctx) + case supportresponse.FieldType: + return m.OldType(ctx) + case supportresponse.FieldRtcchannel: + return m.OldRtcchannel(ctx) + case supportresponse.FieldIsread: + return m.OldIsread(ctx) + case supportresponse.FieldCreated: + return m.OldCreated(ctx) + } + return nil, fmt.Errorf("unknown SupportResponse field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SupportResponseMutation) SetField(name string, value ent.Value) error { + switch name { + case supportresponse.FieldRefid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefid(v) + return nil + case supportresponse.FieldWriter: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWriter(v) + return nil + case supportresponse.FieldMessage: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMessage(v) + return nil + case supportresponse.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case supportresponse.FieldRtcchannel: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRtcchannel(v) + return nil + case supportresponse.FieldIsread: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsread(v) + return nil + case supportresponse.FieldCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreated(v) + return nil + } + return fmt.Errorf("unknown SupportResponse field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *SupportResponseMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *SupportResponseMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *SupportResponseMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown SupportResponse numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *SupportResponseMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *SupportResponseMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *SupportResponseMutation) ClearField(name string) error { + return fmt.Errorf("unknown SupportResponse nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *SupportResponseMutation) ResetField(name string) error { + switch name { + case supportresponse.FieldRefid: + m.ResetRefid() + return nil + case supportresponse.FieldWriter: + m.ResetWriter() + return nil + case supportresponse.FieldMessage: + m.ResetMessage() + return nil + case supportresponse.FieldType: + m.ResetType() + return nil + case supportresponse.FieldRtcchannel: + m.ResetRtcchannel() + return nil + case supportresponse.FieldIsread: + m.ResetIsread() + return nil + case supportresponse.FieldCreated: + m.ResetCreated() + return nil + } + return fmt.Errorf("unknown SupportResponse field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *SupportResponseMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *SupportResponseMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *SupportResponseMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *SupportResponseMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *SupportResponseMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *SupportResponseMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *SupportResponseMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown SupportResponse unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *SupportResponseMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown SupportResponse edge %s", name) +} + +// UserMutation represents an operation that mutates the User nodes in the graph. +type UserMutation struct { + config + op Op + typ string + id *int + serverid *string + userid *string + username *string + xp *int + addxp *int + level *int + addlevel *int + msgs *int + addmsgs *int + created *time.Time + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*User, error) + predicates []predicate.User +} + +var _ ent.Mutation = (*UserMutation)(nil) + +// userOption allows management of the mutation configuration using functional options. +type userOption func(*UserMutation) + +// newUserMutation creates new mutation for the User entity. +func newUserMutation(c config, op Op, opts ...userOption) *UserMutation { + m := &UserMutation{ + config: c, + op: op, + typ: TypeUser, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withUserID sets the ID field of the mutation. +func withUserID(id int) userOption { + return func(m *UserMutation) { + var ( + err error + once sync.Once + value *User + ) + m.oldValue = func(ctx context.Context) (*User, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().User.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withUser sets the old User of the mutation. +func withUser(node *User) userOption { + return func(m *UserMutation) { + m.oldValue = func(context.Context) (*User, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m UserMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m UserMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of User entities. +func (m *UserMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *UserMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *UserMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().User.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetServerid sets the "serverid" field. +func (m *UserMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *UserMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *UserMutation) ResetServerid() { + m.serverid = nil +} + +// SetUserid sets the "userid" field. +func (m *UserMutation) SetUserid(s string) { + m.userid = &s +} + +// Userid returns the value of the "userid" field in the mutation. +func (m *UserMutation) Userid() (r string, exists bool) { + v := m.userid + if v == nil { + return + } + return *v, true +} + +// OldUserid returns the old "userid" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUserid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUserid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUserid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUserid: %w", err) + } + return oldValue.Userid, nil +} + +// ResetUserid resets all changes to the "userid" field. +func (m *UserMutation) ResetUserid() { + m.userid = nil +} + +// SetUsername sets the "username" field. +func (m *UserMutation) SetUsername(s string) { + m.username = &s +} + +// Username returns the value of the "username" field in the mutation. +func (m *UserMutation) Username() (r string, exists bool) { + v := m.username + if v == nil { + return + } + return *v, true +} + +// OldUsername returns the old "username" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldUsername(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldUsername is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldUsername requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldUsername: %w", err) + } + return oldValue.Username, nil +} + +// ResetUsername resets all changes to the "username" field. +func (m *UserMutation) ResetUsername() { + m.username = nil +} + +// SetXp sets the "xp" field. +func (m *UserMutation) SetXp(i int) { + m.xp = &i + m.addxp = nil +} + +// Xp returns the value of the "xp" field in the mutation. +func (m *UserMutation) Xp() (r int, exists bool) { + v := m.xp + if v == nil { + return + } + return *v, true +} + +// OldXp returns the old "xp" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldXp(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldXp is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldXp requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldXp: %w", err) + } + return oldValue.Xp, nil +} + +// AddXp adds i to the "xp" field. +func (m *UserMutation) AddXp(i int) { + if m.addxp != nil { + *m.addxp += i + } else { + m.addxp = &i + } +} + +// AddedXp returns the value that was added to the "xp" field in this mutation. +func (m *UserMutation) AddedXp() (r int, exists bool) { + v := m.addxp + if v == nil { + return + } + return *v, true +} + +// ResetXp resets all changes to the "xp" field. +func (m *UserMutation) ResetXp() { + m.xp = nil + m.addxp = nil +} + +// SetLevel sets the "level" field. +func (m *UserMutation) SetLevel(i int) { + m.level = &i + m.addlevel = nil +} + +// Level returns the value of the "level" field in the mutation. +func (m *UserMutation) Level() (r int, exists bool) { + v := m.level + if v == nil { + return + } + return *v, true +} + +// OldLevel returns the old "level" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldLevel(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldLevel is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldLevel requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldLevel: %w", err) + } + return oldValue.Level, nil +} + +// AddLevel adds i to the "level" field. +func (m *UserMutation) AddLevel(i int) { + if m.addlevel != nil { + *m.addlevel += i + } else { + m.addlevel = &i + } +} + +// AddedLevel returns the value that was added to the "level" field in this mutation. +func (m *UserMutation) AddedLevel() (r int, exists bool) { + v := m.addlevel + if v == nil { + return + } + return *v, true +} + +// ResetLevel resets all changes to the "level" field. +func (m *UserMutation) ResetLevel() { + m.level = nil + m.addlevel = nil +} + +// SetMsgs sets the "msgs" field. +func (m *UserMutation) SetMsgs(i int) { + m.msgs = &i + m.addmsgs = nil +} + +// Msgs returns the value of the "msgs" field in the mutation. +func (m *UserMutation) Msgs() (r int, exists bool) { + v := m.msgs + if v == nil { + return + } + return *v, true +} + +// OldMsgs returns the old "msgs" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldMsgs(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldMsgs is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldMsgs requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldMsgs: %w", err) + } + return oldValue.Msgs, nil +} + +// AddMsgs adds i to the "msgs" field. +func (m *UserMutation) AddMsgs(i int) { + if m.addmsgs != nil { + *m.addmsgs += i + } else { + m.addmsgs = &i + } +} + +// AddedMsgs returns the value that was added to the "msgs" field in this mutation. +func (m *UserMutation) AddedMsgs() (r int, exists bool) { + v := m.addmsgs + if v == nil { + return + } + return *v, true +} + +// ResetMsgs resets all changes to the "msgs" field. +func (m *UserMutation) ResetMsgs() { + m.msgs = nil + m.addmsgs = nil +} + +// SetCreated sets the "created" field. +func (m *UserMutation) SetCreated(t time.Time) { + m.created = &t +} + +// Created returns the value of the "created" field in the mutation. +func (m *UserMutation) Created() (r time.Time, exists bool) { + v := m.created + if v == nil { + return + } + return *v, true +} + +// OldCreated returns the old "created" field's value of the User entity. +// If the User object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *UserMutation) OldCreated(ctx context.Context) (v time.Time, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldCreated is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldCreated requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldCreated: %w", err) + } + return oldValue.Created, nil +} + +// ResetCreated resets all changes to the "created" field. +func (m *UserMutation) ResetCreated() { + m.created = nil +} + +// Where appends a list predicates to the UserMutation builder. +func (m *UserMutation) Where(ps ...predicate.User) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *UserMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (User). +func (m *UserMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *UserMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.serverid != nil { + fields = append(fields, user.FieldServerid) + } + if m.userid != nil { + fields = append(fields, user.FieldUserid) + } + if m.username != nil { + fields = append(fields, user.FieldUsername) + } + if m.xp != nil { + fields = append(fields, user.FieldXp) + } + if m.level != nil { + fields = append(fields, user.FieldLevel) + } + if m.msgs != nil { + fields = append(fields, user.FieldMsgs) + } + if m.created != nil { + fields = append(fields, user.FieldCreated) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *UserMutation) Field(name string) (ent.Value, bool) { + switch name { + case user.FieldServerid: + return m.Serverid() + case user.FieldUserid: + return m.Userid() + case user.FieldUsername: + return m.Username() + case user.FieldXp: + return m.Xp() + case user.FieldLevel: + return m.Level() + case user.FieldMsgs: + return m.Msgs() + case user.FieldCreated: + return m.Created() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case user.FieldServerid: + return m.OldServerid(ctx) + case user.FieldUserid: + return m.OldUserid(ctx) + case user.FieldUsername: + return m.OldUsername(ctx) + case user.FieldXp: + return m.OldXp(ctx) + case user.FieldLevel: + return m.OldLevel(ctx) + case user.FieldMsgs: + return m.OldMsgs(ctx) + case user.FieldCreated: + return m.OldCreated(ctx) + } + return nil, fmt.Errorf("unknown User field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) SetField(name string, value ent.Value) error { + switch name { + case user.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case user.FieldUserid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUserid(v) + return nil + case user.FieldUsername: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetUsername(v) + return nil + case user.FieldXp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetXp(v) + return nil + case user.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetLevel(v) + return nil + case user.FieldMsgs: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetMsgs(v) + return nil + case user.FieldCreated: + v, ok := value.(time.Time) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetCreated(v) + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *UserMutation) AddedFields() []string { + var fields []string + if m.addxp != nil { + fields = append(fields, user.FieldXp) + } + if m.addlevel != nil { + fields = append(fields, user.FieldLevel) + } + if m.addmsgs != nil { + fields = append(fields, user.FieldMsgs) + } + return fields +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *UserMutation) AddedField(name string) (ent.Value, bool) { + switch name { + case user.FieldXp: + return m.AddedXp() + case user.FieldLevel: + return m.AddedLevel() + case user.FieldMsgs: + return m.AddedMsgs() + } + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *UserMutation) AddField(name string, value ent.Value) error { + switch name { + case user.FieldXp: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddXp(v) + return nil + case user.FieldLevel: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddLevel(v) + return nil + case user.FieldMsgs: + v, ok := value.(int) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.AddMsgs(v) + return nil + } + return fmt.Errorf("unknown User numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *UserMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *UserMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *UserMutation) ClearField(name string) error { + return fmt.Errorf("unknown User nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *UserMutation) ResetField(name string) error { + switch name { + case user.FieldServerid: + m.ResetServerid() + return nil + case user.FieldUserid: + m.ResetUserid() + return nil + case user.FieldUsername: + m.ResetUsername() + return nil + case user.FieldXp: + m.ResetXp() + return nil + case user.FieldLevel: + m.ResetLevel() + return nil + case user.FieldMsgs: + m.ResetMsgs() + return nil + case user.FieldCreated: + m.ResetCreated() + return nil + } + return fmt.Errorf("unknown User field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *UserMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *UserMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *UserMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *UserMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *UserMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *UserMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *UserMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown User unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *UserMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown User edge %s", name) +} + +// WarnsMutation represents an operation that mutates the Warns nodes in the graph. +type WarnsMutation struct { + config + op Op + typ string + id *int + emitter *string + serverid *string + target *string + _type *string + duration *string + reason *string + refid *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*Warns, error) + predicates []predicate.Warns +} + +var _ ent.Mutation = (*WarnsMutation)(nil) + +// warnsOption allows management of the mutation configuration using functional options. +type warnsOption func(*WarnsMutation) + +// newWarnsMutation creates new mutation for the Warns entity. +func newWarnsMutation(c config, op Op, opts ...warnsOption) *WarnsMutation { + m := &WarnsMutation{ + config: c, + op: op, + typ: TypeWarns, + clearedFields: make(map[string]struct{}), + } + for _, opt := range opts { + opt(m) + } + return m +} + +// withWarnsID sets the ID field of the mutation. +func withWarnsID(id int) warnsOption { + return func(m *WarnsMutation) { + var ( + err error + once sync.Once + value *Warns + ) + m.oldValue = func(ctx context.Context) (*Warns, error) { + once.Do(func() { + if m.done { + err = errors.New("querying old values post mutation is not allowed") + } else { + value, err = m.Client().Warns.Get(ctx, id) + } + }) + return value, err + } + m.id = &id + } +} + +// withWarns sets the old Warns of the mutation. +func withWarns(node *Warns) warnsOption { + return func(m *WarnsMutation) { + m.oldValue = func(context.Context) (*Warns, error) { + return node, nil + } + m.id = &node.ID + } +} + +// Client returns a new `ent.Client` from the mutation. If the mutation was +// executed in a transaction (ent.Tx), a transactional client is returned. +func (m WarnsMutation) Client() *Client { + client := &Client{config: m.config} + client.init() + return client +} + +// Tx returns an `ent.Tx` for mutations that were executed in transactions; +// it returns an error otherwise. +func (m WarnsMutation) Tx() (*Tx, error) { + if _, ok := m.driver.(*txDriver); !ok { + return nil, errors.New("ent: mutation is not running in a transaction") + } + tx := &Tx{config: m.config} + tx.init() + return tx, nil +} + +// SetID sets the value of the id field. Note that this +// operation is only accepted on creation of Warns entities. +func (m *WarnsMutation) SetID(id int) { + m.id = &id +} + +// ID returns the ID value in the mutation. Note that the ID is only available +// if it was provided to the builder or after it was returned from the database. +func (m *WarnsMutation) ID() (id int, exists bool) { + if m.id == nil { + return + } + return *m.id, true +} + +// IDs queries the database and returns the entity ids that match the mutation's predicate. +// That means, if the mutation is applied within a transaction with an isolation level such +// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated +// or updated by the mutation. +func (m *WarnsMutation) IDs(ctx context.Context) ([]int, error) { + switch { + case m.op.Is(OpUpdateOne | OpDeleteOne): + id, exists := m.ID() + if exists { + return []int{id}, nil + } + fallthrough + case m.op.Is(OpUpdate | OpDelete): + return m.Client().Warns.Query().Where(m.predicates...).IDs(ctx) + default: + return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op) + } +} + +// SetEmitter sets the "emitter" field. +func (m *WarnsMutation) SetEmitter(s string) { + m.emitter = &s +} + +// Emitter returns the value of the "emitter" field in the mutation. +func (m *WarnsMutation) Emitter() (r string, exists bool) { + v := m.emitter + if v == nil { + return + } + return *v, true +} + +// OldEmitter returns the old "emitter" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldEmitter(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldEmitter is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldEmitter requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldEmitter: %w", err) + } + return oldValue.Emitter, nil +} + +// ResetEmitter resets all changes to the "emitter" field. +func (m *WarnsMutation) ResetEmitter() { + m.emitter = nil +} + +// SetServerid sets the "serverid" field. +func (m *WarnsMutation) SetServerid(s string) { + m.serverid = &s +} + +// Serverid returns the value of the "serverid" field in the mutation. +func (m *WarnsMutation) Serverid() (r string, exists bool) { + v := m.serverid + if v == nil { + return + } + return *v, true +} + +// OldServerid returns the old "serverid" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldServerid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldServerid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldServerid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldServerid: %w", err) + } + return oldValue.Serverid, nil +} + +// ResetServerid resets all changes to the "serverid" field. +func (m *WarnsMutation) ResetServerid() { + m.serverid = nil +} + +// SetTarget sets the "target" field. +func (m *WarnsMutation) SetTarget(s string) { + m.target = &s +} + +// Target returns the value of the "target" field in the mutation. +func (m *WarnsMutation) Target() (r string, exists bool) { + v := m.target + if v == nil { + return + } + return *v, true +} + +// OldTarget returns the old "target" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldTarget(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldTarget is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldTarget requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldTarget: %w", err) + } + return oldValue.Target, nil +} + +// ResetTarget resets all changes to the "target" field. +func (m *WarnsMutation) ResetTarget() { + m.target = nil +} + +// SetType sets the "type" field. +func (m *WarnsMutation) SetType(s string) { + m._type = &s +} + +// GetType returns the value of the "type" field in the mutation. +func (m *WarnsMutation) GetType() (r string, exists bool) { + v := m._type + if v == nil { + return + } + return *v, true +} + +// OldType returns the old "type" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldType(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldType is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldType requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldType: %w", err) + } + return oldValue.Type, nil +} + +// ResetType resets all changes to the "type" field. +func (m *WarnsMutation) ResetType() { + m._type = nil +} + +// SetDuration sets the "duration" field. +func (m *WarnsMutation) SetDuration(s string) { + m.duration = &s +} + +// Duration returns the value of the "duration" field in the mutation. +func (m *WarnsMutation) Duration() (r string, exists bool) { + v := m.duration + if v == nil { + return + } + return *v, true +} + +// OldDuration returns the old "duration" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldDuration(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldDuration is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldDuration requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldDuration: %w", err) + } + return oldValue.Duration, nil +} + +// ResetDuration resets all changes to the "duration" field. +func (m *WarnsMutation) ResetDuration() { + m.duration = nil +} + +// SetReason sets the "reason" field. +func (m *WarnsMutation) SetReason(s string) { + m.reason = &s +} + +// Reason returns the value of the "reason" field in the mutation. +func (m *WarnsMutation) Reason() (r string, exists bool) { + v := m.reason + if v == nil { + return + } + return *v, true +} + +// OldReason returns the old "reason" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldReason(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldReason is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldReason requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldReason: %w", err) + } + return oldValue.Reason, nil +} + +// ResetReason resets all changes to the "reason" field. +func (m *WarnsMutation) ResetReason() { + m.reason = nil +} + +// SetRefid sets the "refid" field. +func (m *WarnsMutation) SetRefid(s string) { + m.refid = &s +} + +// Refid returns the value of the "refid" field in the mutation. +func (m *WarnsMutation) Refid() (r string, exists bool) { + v := m.refid + if v == nil { + return + } + return *v, true +} + +// OldRefid returns the old "refid" field's value of the Warns entity. +// If the Warns object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WarnsMutation) OldRefid(ctx context.Context) (v string, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldRefid is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldRefid requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldRefid: %w", err) + } + return oldValue.Refid, nil +} + +// ResetRefid resets all changes to the "refid" field. +func (m *WarnsMutation) ResetRefid() { + m.refid = nil +} + +// Where appends a list predicates to the WarnsMutation builder. +func (m *WarnsMutation) Where(ps ...predicate.Warns) { + m.predicates = append(m.predicates, ps...) +} + +// Op returns the operation name. +func (m *WarnsMutation) Op() Op { + return m.op +} + +// Type returns the node type of this mutation (Warns). +func (m *WarnsMutation) Type() string { + return m.typ +} + +// Fields returns all fields that were changed during this mutation. Note that in +// order to get all numeric fields that were incremented/decremented, call +// AddedFields(). +func (m *WarnsMutation) Fields() []string { + fields := make([]string, 0, 7) + if m.emitter != nil { + fields = append(fields, warns.FieldEmitter) + } + if m.serverid != nil { + fields = append(fields, warns.FieldServerid) + } + if m.target != nil { + fields = append(fields, warns.FieldTarget) + } + if m._type != nil { + fields = append(fields, warns.FieldType) + } + if m.duration != nil { + fields = append(fields, warns.FieldDuration) + } + if m.reason != nil { + fields = append(fields, warns.FieldReason) + } + if m.refid != nil { + fields = append(fields, warns.FieldRefid) + } + return fields +} + +// Field returns the value of a field with the given name. The second boolean +// return value indicates that this field was not set, or was not defined in the +// schema. +func (m *WarnsMutation) Field(name string) (ent.Value, bool) { + switch name { + case warns.FieldEmitter: + return m.Emitter() + case warns.FieldServerid: + return m.Serverid() + case warns.FieldTarget: + return m.Target() + case warns.FieldType: + return m.GetType() + case warns.FieldDuration: + return m.Duration() + case warns.FieldReason: + return m.Reason() + case warns.FieldRefid: + return m.Refid() + } + return nil, false +} + +// OldField returns the old value of the field from the database. An error is +// returned if the mutation operation is not UpdateOne, or the query to the +// database failed. +func (m *WarnsMutation) OldField(ctx context.Context, name string) (ent.Value, error) { + switch name { + case warns.FieldEmitter: + return m.OldEmitter(ctx) + case warns.FieldServerid: + return m.OldServerid(ctx) + case warns.FieldTarget: + return m.OldTarget(ctx) + case warns.FieldType: + return m.OldType(ctx) + case warns.FieldDuration: + return m.OldDuration(ctx) + case warns.FieldReason: + return m.OldReason(ctx) + case warns.FieldRefid: + return m.OldRefid(ctx) + } + return nil, fmt.Errorf("unknown Warns field %s", name) +} + +// SetField sets the value of a field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WarnsMutation) SetField(name string, value ent.Value) error { + switch name { + case warns.FieldEmitter: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetEmitter(v) + return nil + case warns.FieldServerid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetServerid(v) + return nil + case warns.FieldTarget: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetTarget(v) + return nil + case warns.FieldType: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetType(v) + return nil + case warns.FieldDuration: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetDuration(v) + return nil + case warns.FieldReason: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetReason(v) + return nil + case warns.FieldRefid: + v, ok := value.(string) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetRefid(v) + return nil + } + return fmt.Errorf("unknown Warns field %s", name) +} + +// AddedFields returns all numeric fields that were incremented/decremented during +// this mutation. +func (m *WarnsMutation) AddedFields() []string { + return nil +} + +// AddedField returns the numeric value that was incremented/decremented on a field +// with the given name. The second boolean return value indicates that this field +// was not set, or was not defined in the schema. +func (m *WarnsMutation) AddedField(name string) (ent.Value, bool) { + return nil, false +} + +// AddField adds the value to the field with the given name. It returns an error if +// the field is not defined in the schema, or if the type mismatched the field +// type. +func (m *WarnsMutation) AddField(name string, value ent.Value) error { + switch name { + } + return fmt.Errorf("unknown Warns numeric field %s", name) +} + +// ClearedFields returns all nullable fields that were cleared during this +// mutation. +func (m *WarnsMutation) ClearedFields() []string { + return nil +} + +// FieldCleared returns a boolean indicating if a field with the given name was +// cleared in this mutation. +func (m *WarnsMutation) FieldCleared(name string) bool { + _, ok := m.clearedFields[name] + return ok +} + +// ClearField clears the value of the field with the given name. It returns an +// error if the field is not defined in the schema. +func (m *WarnsMutation) ClearField(name string) error { + return fmt.Errorf("unknown Warns nullable field %s", name) +} + +// ResetField resets all changes in the mutation for the field with the given name. +// It returns an error if the field is not defined in the schema. +func (m *WarnsMutation) ResetField(name string) error { + switch name { + case warns.FieldEmitter: + m.ResetEmitter() + return nil + case warns.FieldServerid: + m.ResetServerid() + return nil + case warns.FieldTarget: + m.ResetTarget() + return nil + case warns.FieldType: + m.ResetType() + return nil + case warns.FieldDuration: + m.ResetDuration() + return nil + case warns.FieldReason: + m.ResetReason() + return nil + case warns.FieldRefid: + m.ResetRefid() + return nil + } + return fmt.Errorf("unknown Warns field %s", name) +} + +// AddedEdges returns all edge names that were set/added in this mutation. +func (m *WarnsMutation) AddedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// AddedIDs returns all IDs (to other nodes) that were added for the given edge +// name in this mutation. +func (m *WarnsMutation) AddedIDs(name string) []ent.Value { + return nil +} + +// RemovedEdges returns all edge names that were removed in this mutation. +func (m *WarnsMutation) RemovedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with +// the given name in this mutation. +func (m *WarnsMutation) RemovedIDs(name string) []ent.Value { + return nil +} + +// ClearedEdges returns all edge names that were cleared in this mutation. +func (m *WarnsMutation) ClearedEdges() []string { + edges := make([]string, 0, 0) + return edges +} + +// EdgeCleared returns a boolean which indicates if the edge with the given name +// was cleared in this mutation. +func (m *WarnsMutation) EdgeCleared(name string) bool { + return false +} + +// ClearEdge clears the value of the edge with the given name. It returns an error +// if that edge is not defined in the schema. +func (m *WarnsMutation) ClearEdge(name string) error { + return fmt.Errorf("unknown Warns unique edge %s", name) +} + +// ResetEdge resets all changes to the edge with the given name in this mutation. +// It returns an error if the edge is not defined in the schema. +func (m *WarnsMutation) ResetEdge(name string) error { + return fmt.Errorf("unknown Warns edge %s", name) +} diff --git a/ent/predicate/predicate.go b/ent/predicate/predicate.go new file mode 100644 index 0000000..10bb7c2 --- /dev/null +++ b/ent/predicate/predicate.go @@ -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) diff --git a/ent/punishments.go b/ent/punishments.go new file mode 100644 index 0000000..805949e --- /dev/null +++ b/ent/punishments.go @@ -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 + } +} diff --git a/ent/punishments/punishments.go b/ent/punishments/punishments.go new file mode 100644 index 0000000..03c3339 --- /dev/null +++ b/ent/punishments/punishments.go @@ -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 +} diff --git a/ent/punishments/where.go b/ent/punishments/where.go new file mode 100644 index 0000000..2392243 --- /dev/null +++ b/ent/punishments/where.go @@ -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()) + }) +} diff --git a/ent/punishments_create.go b/ent/punishments_create.go new file mode 100644 index 0000000..6d7ad69 --- /dev/null +++ b/ent/punishments_create.go @@ -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) + } +} diff --git a/ent/punishments_delete.go b/ent/punishments_delete.go new file mode 100644 index 0000000..9b0406c --- /dev/null +++ b/ent/punishments_delete.go @@ -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) +} diff --git a/ent/punishments_query.go b/ent/punishments_query.go new file mode 100644 index 0000000..bc977fa --- /dev/null +++ b/ent/punishments_query.go @@ -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) +} diff --git a/ent/punishments_update.go b/ent/punishments_update.go new file mode 100644 index 0000000..f891203 --- /dev/null +++ b/ent/punishments_update.go @@ -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 +} diff --git a/ent/runtime.go b/ent/runtime.go new file mode 100644 index 0000000..90a205b --- /dev/null +++ b/ent/runtime.go @@ -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) +} diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go new file mode 100644 index 0000000..752698b --- /dev/null +++ b/ent/runtime/runtime.go @@ -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. +) diff --git a/ent/schema/actions.go b/ent/schema/actions.go new file mode 100644 index 0000000..480dfa2 --- /dev/null +++ b/ent/schema/actions.go @@ -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 +} diff --git a/ent/schema/authorizables.go b/ent/schema/authorizables.go new file mode 100644 index 0000000..3045cbd --- /dev/null +++ b/ent/schema/authorizables.go @@ -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 +} diff --git a/ent/schema/blacklist.go b/ent/schema/blacklist.go new file mode 100644 index 0000000..ded6226 --- /dev/null +++ b/ent/schema/blacklist.go @@ -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 +} diff --git a/ent/schema/logging.go b/ent/schema/logging.go new file mode 100644 index 0000000..0e6614f --- /dev/null +++ b/ent/schema/logging.go @@ -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 +} diff --git a/ent/schema/punishments.go b/ent/schema/punishments.go new file mode 100644 index 0000000..78253b4 --- /dev/null +++ b/ent/schema/punishments.go @@ -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 +} diff --git a/ent/schema/servers.go b/ent/schema/servers.go new file mode 100644 index 0000000..d6f30c5 --- /dev/null +++ b/ent/schema/servers.go @@ -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 +} diff --git a/ent/schema/settings.go b/ent/schema/settings.go new file mode 100644 index 0000000..098ee79 --- /dev/null +++ b/ent/schema/settings.go @@ -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 +} diff --git a/ent/schema/socialmedia.go b/ent/schema/socialmedia.go new file mode 100644 index 0000000..a798fd1 --- /dev/null +++ b/ent/schema/socialmedia.go @@ -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 +} diff --git a/ent/schema/support.go b/ent/schema/support.go new file mode 100644 index 0000000..033f98e --- /dev/null +++ b/ent/schema/support.go @@ -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 +} diff --git a/ent/schema/supportresponse.go b/ent/schema/supportresponse.go new file mode 100644 index 0000000..2324223 --- /dev/null +++ b/ent/schema/supportresponse.go @@ -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 +} diff --git a/ent/schema/user.go b/ent/schema/user.go new file mode 100644 index 0000000..7e52ab6 --- /dev/null +++ b/ent/schema/user.go @@ -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 +} diff --git a/ent/schema/warns.go b/ent/schema/warns.go new file mode 100644 index 0000000..28b950f --- /dev/null +++ b/ent/schema/warns.go @@ -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 +} diff --git a/ent/servers.go b/ent/servers.go new file mode 100644 index 0000000..e44bf61 --- /dev/null +++ b/ent/servers.go @@ -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 + } +} diff --git a/ent/servers/servers.go b/ent/servers/servers.go new file mode 100644 index 0000000..5cb8028 --- /dev/null +++ b/ent/servers/servers.go @@ -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 +} diff --git a/ent/servers/where.go b/ent/servers/where.go new file mode 100644 index 0000000..baaaeef --- /dev/null +++ b/ent/servers/where.go @@ -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()) + }) +} diff --git a/ent/servers_create.go b/ent/servers_create.go new file mode 100644 index 0000000..5549809 --- /dev/null +++ b/ent/servers_create.go @@ -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) + } +} diff --git a/ent/servers_delete.go b/ent/servers_delete.go new file mode 100644 index 0000000..c7703fb --- /dev/null +++ b/ent/servers_delete.go @@ -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) +} diff --git a/ent/servers_query.go b/ent/servers_query.go new file mode 100644 index 0000000..3f5efa2 --- /dev/null +++ b/ent/servers_query.go @@ -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) +} diff --git a/ent/servers_update.go b/ent/servers_update.go new file mode 100644 index 0000000..8544f48 --- /dev/null +++ b/ent/servers_update.go @@ -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 +} diff --git a/ent/settings.go b/ent/settings.go new file mode 100644 index 0000000..5fedb8a --- /dev/null +++ b/ent/settings.go @@ -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 + } +} diff --git a/ent/settings/settings.go b/ent/settings/settings.go new file mode 100644 index 0000000..2ed8377 --- /dev/null +++ b/ent/settings/settings.go @@ -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 +) diff --git a/ent/settings/where.go b/ent/settings/where.go new file mode 100644 index 0000000..1348ce0 --- /dev/null +++ b/ent/settings/where.go @@ -0,0 +1,1703 @@ +// Code generated by ent, DO NOT EDIT. + +package settings + +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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldServerid), v)) + }) +} + +// Servername applies equality check predicate on the "servername" field. It's identical to ServernameEQ. +func Servername(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldServername), v)) + }) +} + +// Ownerid applies equality check predicate on the "ownerid" field. It's identical to OwneridEQ. +func Ownerid(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOwnerid), v)) + }) +} + +// Permtoken applies equality check predicate on the "permtoken" field. It's identical to PermtokenEQ. +func Permtoken(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPermtoken), v)) + }) +} + +// Apitoken applies equality check predicate on the "apitoken" field. It's identical to ApitokenEQ. +func Apitoken(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldApitoken), v)) + }) +} + +// Statspagemode applies equality check predicate on the "statspagemode" field. It's identical to StatspagemodeEQ. +func Statspagemode(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatspagemode), v)) + }) +} + +// Loggerchannel applies equality check predicate on the "loggerchannel" field. It's identical to LoggerchannelEQ. +func Loggerchannel(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLoggerchannel), v)) + }) +} + +// Spamchannel applies equality check predicate on the "spamchannel" field. It's identical to SpamchannelEQ. +func Spamchannel(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpamchannel), v)) + }) +} + +// Greeterchannel applies equality check predicate on the "greeterchannel" field. It's identical to GreeterchannelEQ. +func Greeterchannel(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreeterchannel), v)) + }) +} + +// Greetermode applies equality check predicate on the "greetermode" field. It's identical to GreetermodeEQ. +func Greetermode(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreetermode), v)) + }) +} + +// Announcechannel applies equality check predicate on the "announcechannel" field. It's identical to AnnouncechannelEQ. +func Announcechannel(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAnnouncechannel), v)) + }) +} + +// Logger applies equality check predicate on the "logger" field. It's identical to LoggerEQ. +func Logger(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLogger), v)) + }) +} + +// Spamprotection applies equality check predicate on the "spamprotection" field. It's identical to SpamprotectionEQ. +func Spamprotection(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpamprotection), v)) + }) +} + +// Linkprotection applies equality check predicate on the "linkprotection" field. It's identical to LinkprotectionEQ. +func Linkprotection(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLinkprotection), v)) + }) +} + +// Wordfilter applies equality check predicate on the "wordfilter" field. It's identical to WordfilterEQ. +func Wordfilter(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWordfilter), v)) + }) +} + +// Greetings applies equality check predicate on the "greetings" field. It's identical to GreetingsEQ. +func Greetings(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreetings), v)) + }) +} + +// Apitoggle applies equality check predicate on the "apitoggle" field. It's identical to ApitoggleEQ. +func Apitoggle(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldApitoggle), v)) + }) +} + +// Moderation applies equality check predicate on the "moderation" field. It's identical to ModerationEQ. +func Moderation(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldModeration), v)) + }) +} + +// Automatedmoderation applies equality check predicate on the "automatedmoderation" field. It's identical to AutomatedmoderationEQ. +func Automatedmoderation(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAutomatedmoderation), v)) + }) +} + +// Twitchannounce applies equality check predicate on the "twitchannounce" field. It's identical to TwitchannounceEQ. +func Twitchannounce(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTwitchannounce), v)) + }) +} + +// Twitterannounce applies equality check predicate on the "twitterannounce" field. It's identical to TwitterannounceEQ. +func Twitterannounce(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTwitterannounce), v)) + }) +} + +// Music applies equality check predicate on the "music" field. It's identical to MusicEQ. +func Music(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMusic), v)) + }) +} + +// Statspage applies equality check predicate on the "statspage" field. It's identical to StatspageEQ. +func Statspage(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatspage), v)) + }) +} + +// Statsprivate applies equality check predicate on the "statsprivate" field. It's identical to StatsprivateEQ. +func Statsprivate(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatsprivate), v)) + }) +} + +// Stats applies equality check predicate on the "stats" field. It's identical to StatsEQ. +func Stats(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStats), v)) + }) +} + +// ServeridEQ applies the EQ predicate on the "serverid" field. +func ServeridEQ(v string) predicate.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(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.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldServerid), v)) + }) +} + +// ServernameEQ applies the EQ predicate on the "servername" field. +func ServernameEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldServername), v)) + }) +} + +// ServernameNEQ applies the NEQ predicate on the "servername" field. +func ServernameNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldServername), v)) + }) +} + +// ServernameIn applies the In predicate on the "servername" field. +func ServernameIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldServername), v...)) + }) +} + +// ServernameNotIn applies the NotIn predicate on the "servername" field. +func ServernameNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldServername), v...)) + }) +} + +// ServernameGT applies the GT predicate on the "servername" field. +func ServernameGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldServername), v)) + }) +} + +// ServernameGTE applies the GTE predicate on the "servername" field. +func ServernameGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldServername), v)) + }) +} + +// ServernameLT applies the LT predicate on the "servername" field. +func ServernameLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldServername), v)) + }) +} + +// ServernameLTE applies the LTE predicate on the "servername" field. +func ServernameLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldServername), v)) + }) +} + +// ServernameContains applies the Contains predicate on the "servername" field. +func ServernameContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldServername), v)) + }) +} + +// ServernameHasPrefix applies the HasPrefix predicate on the "servername" field. +func ServernameHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldServername), v)) + }) +} + +// ServernameHasSuffix applies the HasSuffix predicate on the "servername" field. +func ServernameHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldServername), v)) + }) +} + +// ServernameEqualFold applies the EqualFold predicate on the "servername" field. +func ServernameEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldServername), v)) + }) +} + +// ServernameContainsFold applies the ContainsFold predicate on the "servername" field. +func ServernameContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldServername), v)) + }) +} + +// OwneridEQ applies the EQ predicate on the "ownerid" field. +func OwneridEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOwnerid), v)) + }) +} + +// OwneridNEQ applies the NEQ predicate on the "ownerid" field. +func OwneridNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOwnerid), v)) + }) +} + +// OwneridIn applies the In predicate on the "ownerid" field. +func OwneridIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldOwnerid), v...)) + }) +} + +// OwneridNotIn applies the NotIn predicate on the "ownerid" field. +func OwneridNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldOwnerid), v...)) + }) +} + +// OwneridGT applies the GT predicate on the "ownerid" field. +func OwneridGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOwnerid), v)) + }) +} + +// OwneridGTE applies the GTE predicate on the "ownerid" field. +func OwneridGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOwnerid), v)) + }) +} + +// OwneridLT applies the LT predicate on the "ownerid" field. +func OwneridLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOwnerid), v)) + }) +} + +// OwneridLTE applies the LTE predicate on the "ownerid" field. +func OwneridLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOwnerid), v)) + }) +} + +// OwneridContains applies the Contains predicate on the "ownerid" field. +func OwneridContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldOwnerid), v)) + }) +} + +// OwneridHasPrefix applies the HasPrefix predicate on the "ownerid" field. +func OwneridHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldOwnerid), v)) + }) +} + +// OwneridHasSuffix applies the HasSuffix predicate on the "ownerid" field. +func OwneridHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldOwnerid), v)) + }) +} + +// OwneridEqualFold applies the EqualFold predicate on the "ownerid" field. +func OwneridEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldOwnerid), v)) + }) +} + +// OwneridContainsFold applies the ContainsFold predicate on the "ownerid" field. +func OwneridContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldOwnerid), v)) + }) +} + +// PermtokenEQ applies the EQ predicate on the "permtoken" field. +func PermtokenEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenNEQ applies the NEQ predicate on the "permtoken" field. +func PermtokenNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenIn applies the In predicate on the "permtoken" field. +func PermtokenIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldPermtoken), v...)) + }) +} + +// PermtokenNotIn applies the NotIn predicate on the "permtoken" field. +func PermtokenNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldPermtoken), v...)) + }) +} + +// PermtokenGT applies the GT predicate on the "permtoken" field. +func PermtokenGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenGTE applies the GTE predicate on the "permtoken" field. +func PermtokenGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenLT applies the LT predicate on the "permtoken" field. +func PermtokenLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenLTE applies the LTE predicate on the "permtoken" field. +func PermtokenLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenContains applies the Contains predicate on the "permtoken" field. +func PermtokenContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenHasPrefix applies the HasPrefix predicate on the "permtoken" field. +func PermtokenHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenHasSuffix applies the HasSuffix predicate on the "permtoken" field. +func PermtokenHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenEqualFold applies the EqualFold predicate on the "permtoken" field. +func PermtokenEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldPermtoken), v)) + }) +} + +// PermtokenContainsFold applies the ContainsFold predicate on the "permtoken" field. +func PermtokenContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldPermtoken), v)) + }) +} + +// ApitokenEQ applies the EQ predicate on the "apitoken" field. +func ApitokenEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldApitoken), v)) + }) +} + +// ApitokenNEQ applies the NEQ predicate on the "apitoken" field. +func ApitokenNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldApitoken), v)) + }) +} + +// ApitokenIn applies the In predicate on the "apitoken" field. +func ApitokenIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldApitoken), v...)) + }) +} + +// ApitokenNotIn applies the NotIn predicate on the "apitoken" field. +func ApitokenNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldApitoken), v...)) + }) +} + +// ApitokenGT applies the GT predicate on the "apitoken" field. +func ApitokenGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldApitoken), v)) + }) +} + +// ApitokenGTE applies the GTE predicate on the "apitoken" field. +func ApitokenGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldApitoken), v)) + }) +} + +// ApitokenLT applies the LT predicate on the "apitoken" field. +func ApitokenLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldApitoken), v)) + }) +} + +// ApitokenLTE applies the LTE predicate on the "apitoken" field. +func ApitokenLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldApitoken), v)) + }) +} + +// ApitokenContains applies the Contains predicate on the "apitoken" field. +func ApitokenContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldApitoken), v)) + }) +} + +// ApitokenHasPrefix applies the HasPrefix predicate on the "apitoken" field. +func ApitokenHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldApitoken), v)) + }) +} + +// ApitokenHasSuffix applies the HasSuffix predicate on the "apitoken" field. +func ApitokenHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldApitoken), v)) + }) +} + +// ApitokenEqualFold applies the EqualFold predicate on the "apitoken" field. +func ApitokenEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldApitoken), v)) + }) +} + +// ApitokenContainsFold applies the ContainsFold predicate on the "apitoken" field. +func ApitokenContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldApitoken), v)) + }) +} + +// StatspagemodeEQ applies the EQ predicate on the "statspagemode" field. +func StatspagemodeEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeNEQ applies the NEQ predicate on the "statspagemode" field. +func StatspagemodeNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeIn applies the In predicate on the "statspagemode" field. +func StatspagemodeIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldStatspagemode), v...)) + }) +} + +// StatspagemodeNotIn applies the NotIn predicate on the "statspagemode" field. +func StatspagemodeNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldStatspagemode), v...)) + }) +} + +// StatspagemodeGT applies the GT predicate on the "statspagemode" field. +func StatspagemodeGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeGTE applies the GTE predicate on the "statspagemode" field. +func StatspagemodeGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeLT applies the LT predicate on the "statspagemode" field. +func StatspagemodeLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeLTE applies the LTE predicate on the "statspagemode" field. +func StatspagemodeLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeContains applies the Contains predicate on the "statspagemode" field. +func StatspagemodeContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeHasPrefix applies the HasPrefix predicate on the "statspagemode" field. +func StatspagemodeHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeHasSuffix applies the HasSuffix predicate on the "statspagemode" field. +func StatspagemodeHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeEqualFold applies the EqualFold predicate on the "statspagemode" field. +func StatspagemodeEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldStatspagemode), v)) + }) +} + +// StatspagemodeContainsFold applies the ContainsFold predicate on the "statspagemode" field. +func StatspagemodeContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldStatspagemode), v)) + }) +} + +// LoggerchannelEQ applies the EQ predicate on the "loggerchannel" field. +func LoggerchannelEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelNEQ applies the NEQ predicate on the "loggerchannel" field. +func LoggerchannelNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelIn applies the In predicate on the "loggerchannel" field. +func LoggerchannelIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldLoggerchannel), v...)) + }) +} + +// LoggerchannelNotIn applies the NotIn predicate on the "loggerchannel" field. +func LoggerchannelNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldLoggerchannel), v...)) + }) +} + +// LoggerchannelGT applies the GT predicate on the "loggerchannel" field. +func LoggerchannelGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelGTE applies the GTE predicate on the "loggerchannel" field. +func LoggerchannelGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelLT applies the LT predicate on the "loggerchannel" field. +func LoggerchannelLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelLTE applies the LTE predicate on the "loggerchannel" field. +func LoggerchannelLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelContains applies the Contains predicate on the "loggerchannel" field. +func LoggerchannelContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelHasPrefix applies the HasPrefix predicate on the "loggerchannel" field. +func LoggerchannelHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelHasSuffix applies the HasSuffix predicate on the "loggerchannel" field. +func LoggerchannelHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelEqualFold applies the EqualFold predicate on the "loggerchannel" field. +func LoggerchannelEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldLoggerchannel), v)) + }) +} + +// LoggerchannelContainsFold applies the ContainsFold predicate on the "loggerchannel" field. +func LoggerchannelContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldLoggerchannel), v)) + }) +} + +// SpamchannelEQ applies the EQ predicate on the "spamchannel" field. +func SpamchannelEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelNEQ applies the NEQ predicate on the "spamchannel" field. +func SpamchannelNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelIn applies the In predicate on the "spamchannel" field. +func SpamchannelIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldSpamchannel), v...)) + }) +} + +// SpamchannelNotIn applies the NotIn predicate on the "spamchannel" field. +func SpamchannelNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldSpamchannel), v...)) + }) +} + +// SpamchannelGT applies the GT predicate on the "spamchannel" field. +func SpamchannelGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelGTE applies the GTE predicate on the "spamchannel" field. +func SpamchannelGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelLT applies the LT predicate on the "spamchannel" field. +func SpamchannelLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelLTE applies the LTE predicate on the "spamchannel" field. +func SpamchannelLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelContains applies the Contains predicate on the "spamchannel" field. +func SpamchannelContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelHasPrefix applies the HasPrefix predicate on the "spamchannel" field. +func SpamchannelHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelHasSuffix applies the HasSuffix predicate on the "spamchannel" field. +func SpamchannelHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelEqualFold applies the EqualFold predicate on the "spamchannel" field. +func SpamchannelEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldSpamchannel), v)) + }) +} + +// SpamchannelContainsFold applies the ContainsFold predicate on the "spamchannel" field. +func SpamchannelContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldSpamchannel), v)) + }) +} + +// GreeterchannelEQ applies the EQ predicate on the "greeterchannel" field. +func GreeterchannelEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelNEQ applies the NEQ predicate on the "greeterchannel" field. +func GreeterchannelNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelIn applies the In predicate on the "greeterchannel" field. +func GreeterchannelIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldGreeterchannel), v...)) + }) +} + +// GreeterchannelNotIn applies the NotIn predicate on the "greeterchannel" field. +func GreeterchannelNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldGreeterchannel), v...)) + }) +} + +// GreeterchannelGT applies the GT predicate on the "greeterchannel" field. +func GreeterchannelGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelGTE applies the GTE predicate on the "greeterchannel" field. +func GreeterchannelGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelLT applies the LT predicate on the "greeterchannel" field. +func GreeterchannelLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelLTE applies the LTE predicate on the "greeterchannel" field. +func GreeterchannelLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelContains applies the Contains predicate on the "greeterchannel" field. +func GreeterchannelContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelHasPrefix applies the HasPrefix predicate on the "greeterchannel" field. +func GreeterchannelHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelHasSuffix applies the HasSuffix predicate on the "greeterchannel" field. +func GreeterchannelHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelEqualFold applies the EqualFold predicate on the "greeterchannel" field. +func GreeterchannelEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldGreeterchannel), v)) + }) +} + +// GreeterchannelContainsFold applies the ContainsFold predicate on the "greeterchannel" field. +func GreeterchannelContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldGreeterchannel), v)) + }) +} + +// GreetermodeEQ applies the EQ predicate on the "greetermode" field. +func GreetermodeEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeNEQ applies the NEQ predicate on the "greetermode" field. +func GreetermodeNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeIn applies the In predicate on the "greetermode" field. +func GreetermodeIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldGreetermode), v...)) + }) +} + +// GreetermodeNotIn applies the NotIn predicate on the "greetermode" field. +func GreetermodeNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldGreetermode), v...)) + }) +} + +// GreetermodeGT applies the GT predicate on the "greetermode" field. +func GreetermodeGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeGTE applies the GTE predicate on the "greetermode" field. +func GreetermodeGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeLT applies the LT predicate on the "greetermode" field. +func GreetermodeLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeLTE applies the LTE predicate on the "greetermode" field. +func GreetermodeLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeContains applies the Contains predicate on the "greetermode" field. +func GreetermodeContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeHasPrefix applies the HasPrefix predicate on the "greetermode" field. +func GreetermodeHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeHasSuffix applies the HasSuffix predicate on the "greetermode" field. +func GreetermodeHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeEqualFold applies the EqualFold predicate on the "greetermode" field. +func GreetermodeEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldGreetermode), v)) + }) +} + +// GreetermodeContainsFold applies the ContainsFold predicate on the "greetermode" field. +func GreetermodeContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldGreetermode), v)) + }) +} + +// AnnouncechannelEQ applies the EQ predicate on the "announcechannel" field. +func AnnouncechannelEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelNEQ applies the NEQ predicate on the "announcechannel" field. +func AnnouncechannelNEQ(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelIn applies the In predicate on the "announcechannel" field. +func AnnouncechannelIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldAnnouncechannel), v...)) + }) +} + +// AnnouncechannelNotIn applies the NotIn predicate on the "announcechannel" field. +func AnnouncechannelNotIn(vs ...string) predicate.Settings { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Settings(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(FieldAnnouncechannel), v...)) + }) +} + +// AnnouncechannelGT applies the GT predicate on the "announcechannel" field. +func AnnouncechannelGT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelGTE applies the GTE predicate on the "announcechannel" field. +func AnnouncechannelGTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelLT applies the LT predicate on the "announcechannel" field. +func AnnouncechannelLT(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelLTE applies the LTE predicate on the "announcechannel" field. +func AnnouncechannelLTE(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelContains applies the Contains predicate on the "announcechannel" field. +func AnnouncechannelContains(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelHasPrefix applies the HasPrefix predicate on the "announcechannel" field. +func AnnouncechannelHasPrefix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelHasSuffix applies the HasSuffix predicate on the "announcechannel" field. +func AnnouncechannelHasSuffix(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelEqualFold applies the EqualFold predicate on the "announcechannel" field. +func AnnouncechannelEqualFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldAnnouncechannel), v)) + }) +} + +// AnnouncechannelContainsFold applies the ContainsFold predicate on the "announcechannel" field. +func AnnouncechannelContainsFold(v string) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldAnnouncechannel), v)) + }) +} + +// LoggerEQ applies the EQ predicate on the "logger" field. +func LoggerEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLogger), v)) + }) +} + +// LoggerNEQ applies the NEQ predicate on the "logger" field. +func LoggerNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLogger), v)) + }) +} + +// SpamprotectionEQ applies the EQ predicate on the "spamprotection" field. +func SpamprotectionEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldSpamprotection), v)) + }) +} + +// SpamprotectionNEQ applies the NEQ predicate on the "spamprotection" field. +func SpamprotectionNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldSpamprotection), v)) + }) +} + +// LinkprotectionEQ applies the EQ predicate on the "linkprotection" field. +func LinkprotectionEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLinkprotection), v)) + }) +} + +// LinkprotectionNEQ applies the NEQ predicate on the "linkprotection" field. +func LinkprotectionNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLinkprotection), v)) + }) +} + +// WordfilterEQ applies the EQ predicate on the "wordfilter" field. +func WordfilterEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldWordfilter), v)) + }) +} + +// WordfilterNEQ applies the NEQ predicate on the "wordfilter" field. +func WordfilterNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldWordfilter), v)) + }) +} + +// GreetingsEQ applies the EQ predicate on the "greetings" field. +func GreetingsEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldGreetings), v)) + }) +} + +// GreetingsNEQ applies the NEQ predicate on the "greetings" field. +func GreetingsNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldGreetings), v)) + }) +} + +// ApitoggleEQ applies the EQ predicate on the "apitoggle" field. +func ApitoggleEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldApitoggle), v)) + }) +} + +// ApitoggleNEQ applies the NEQ predicate on the "apitoggle" field. +func ApitoggleNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldApitoggle), v)) + }) +} + +// ModerationEQ applies the EQ predicate on the "moderation" field. +func ModerationEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldModeration), v)) + }) +} + +// ModerationNEQ applies the NEQ predicate on the "moderation" field. +func ModerationNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldModeration), v)) + }) +} + +// AutomatedmoderationEQ applies the EQ predicate on the "automatedmoderation" field. +func AutomatedmoderationEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldAutomatedmoderation), v)) + }) +} + +// AutomatedmoderationNEQ applies the NEQ predicate on the "automatedmoderation" field. +func AutomatedmoderationNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldAutomatedmoderation), v)) + }) +} + +// TwitchannounceEQ applies the EQ predicate on the "twitchannounce" field. +func TwitchannounceEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTwitchannounce), v)) + }) +} + +// TwitchannounceNEQ applies the NEQ predicate on the "twitchannounce" field. +func TwitchannounceNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldTwitchannounce), v)) + }) +} + +// TwitterannounceEQ applies the EQ predicate on the "twitterannounce" field. +func TwitterannounceEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldTwitterannounce), v)) + }) +} + +// TwitterannounceNEQ applies the NEQ predicate on the "twitterannounce" field. +func TwitterannounceNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldTwitterannounce), v)) + }) +} + +// MusicEQ applies the EQ predicate on the "music" field. +func MusicEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMusic), v)) + }) +} + +// MusicNEQ applies the NEQ predicate on the "music" field. +func MusicNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMusic), v)) + }) +} + +// StatspageEQ applies the EQ predicate on the "statspage" field. +func StatspageEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatspage), v)) + }) +} + +// StatspageNEQ applies the NEQ predicate on the "statspage" field. +func StatspageNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStatspage), v)) + }) +} + +// StatsprivateEQ applies the EQ predicate on the "statsprivate" field. +func StatsprivateEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStatsprivate), v)) + }) +} + +// StatsprivateNEQ applies the NEQ predicate on the "statsprivate" field. +func StatsprivateNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStatsprivate), v)) + }) +} + +// StatsEQ applies the EQ predicate on the "stats" field. +func StatsEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldStats), v)) + }) +} + +// StatsNEQ applies the NEQ predicate on the "stats" field. +func StatsNEQ(v bool) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldStats), v)) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Settings) predicate.Settings { + return predicate.Settings(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.Settings) predicate.Settings { + return predicate.Settings(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.Settings) predicate.Settings { + return predicate.Settings(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/settings_create.go b/ent/settings_create.go new file mode 100644 index 0000000..ce758d8 --- /dev/null +++ b/ent/settings_create.go @@ -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) + } +} diff --git a/ent/settings_delete.go b/ent/settings_delete.go new file mode 100644 index 0000000..45964df --- /dev/null +++ b/ent/settings_delete.go @@ -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) +} diff --git a/ent/settings_query.go b/ent/settings_query.go new file mode 100644 index 0000000..25d8853 --- /dev/null +++ b/ent/settings_query.go @@ -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) +} diff --git a/ent/settings_update.go b/ent/settings_update.go new file mode 100644 index 0000000..47e4277 --- /dev/null +++ b/ent/settings_update.go @@ -0,0 +1,1119 @@ +// 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/settings" +) + +// SettingsUpdate is the builder for updating Settings entities. +type SettingsUpdate struct { + config + hooks []Hook + mutation *SettingsMutation +} + +// Where appends a list predicates to the SettingsUpdate builder. +func (su *SettingsUpdate) Where(ps ...predicate.Settings) *SettingsUpdate { + su.mutation.Where(ps...) + return su +} + +// SetServerid sets the "serverid" field. +func (su *SettingsUpdate) SetServerid(s string) *SettingsUpdate { + su.mutation.SetServerid(s) + return su +} + +// SetServername sets the "servername" field. +func (su *SettingsUpdate) SetServername(s string) *SettingsUpdate { + su.mutation.SetServername(s) + return su +} + +// SetOwnerid sets the "ownerid" field. +func (su *SettingsUpdate) SetOwnerid(s string) *SettingsUpdate { + su.mutation.SetOwnerid(s) + return su +} + +// SetPermtoken sets the "permtoken" field. +func (su *SettingsUpdate) SetPermtoken(s string) *SettingsUpdate { + su.mutation.SetPermtoken(s) + return su +} + +// SetApitoken sets the "apitoken" field. +func (su *SettingsUpdate) SetApitoken(s string) *SettingsUpdate { + su.mutation.SetApitoken(s) + return su +} + +// SetStatspagemode sets the "statspagemode" field. +func (su *SettingsUpdate) SetStatspagemode(s string) *SettingsUpdate { + su.mutation.SetStatspagemode(s) + return su +} + +// SetLoggerchannel sets the "loggerchannel" field. +func (su *SettingsUpdate) SetLoggerchannel(s string) *SettingsUpdate { + su.mutation.SetLoggerchannel(s) + return su +} + +// SetSpamchannel sets the "spamchannel" field. +func (su *SettingsUpdate) SetSpamchannel(s string) *SettingsUpdate { + su.mutation.SetSpamchannel(s) + return su +} + +// SetGreeterchannel sets the "greeterchannel" field. +func (su *SettingsUpdate) SetGreeterchannel(s string) *SettingsUpdate { + su.mutation.SetGreeterchannel(s) + return su +} + +// SetGreetermode sets the "greetermode" field. +func (su *SettingsUpdate) SetGreetermode(s string) *SettingsUpdate { + su.mutation.SetGreetermode(s) + return su +} + +// SetAnnouncechannel sets the "announcechannel" field. +func (su *SettingsUpdate) SetAnnouncechannel(s string) *SettingsUpdate { + su.mutation.SetAnnouncechannel(s) + return su +} + +// SetLogger sets the "logger" field. +func (su *SettingsUpdate) SetLogger(b bool) *SettingsUpdate { + su.mutation.SetLogger(b) + return su +} + +// SetNillableLogger sets the "logger" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableLogger(b *bool) *SettingsUpdate { + if b != nil { + su.SetLogger(*b) + } + return su +} + +// SetSpamprotection sets the "spamprotection" field. +func (su *SettingsUpdate) SetSpamprotection(b bool) *SettingsUpdate { + su.mutation.SetSpamprotection(b) + return su +} + +// SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableSpamprotection(b *bool) *SettingsUpdate { + if b != nil { + su.SetSpamprotection(*b) + } + return su +} + +// SetLinkprotection sets the "linkprotection" field. +func (su *SettingsUpdate) SetLinkprotection(b bool) *SettingsUpdate { + su.mutation.SetLinkprotection(b) + return su +} + +// SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableLinkprotection(b *bool) *SettingsUpdate { + if b != nil { + su.SetLinkprotection(*b) + } + return su +} + +// SetWordfilter sets the "wordfilter" field. +func (su *SettingsUpdate) SetWordfilter(b bool) *SettingsUpdate { + su.mutation.SetWordfilter(b) + return su +} + +// SetNillableWordfilter sets the "wordfilter" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableWordfilter(b *bool) *SettingsUpdate { + if b != nil { + su.SetWordfilter(*b) + } + return su +} + +// SetGreetings sets the "greetings" field. +func (su *SettingsUpdate) SetGreetings(b bool) *SettingsUpdate { + su.mutation.SetGreetings(b) + return su +} + +// SetNillableGreetings sets the "greetings" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableGreetings(b *bool) *SettingsUpdate { + if b != nil { + su.SetGreetings(*b) + } + return su +} + +// SetApitoggle sets the "apitoggle" field. +func (su *SettingsUpdate) SetApitoggle(b bool) *SettingsUpdate { + su.mutation.SetApitoggle(b) + return su +} + +// SetNillableApitoggle sets the "apitoggle" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableApitoggle(b *bool) *SettingsUpdate { + if b != nil { + su.SetApitoggle(*b) + } + return su +} + +// SetModeration sets the "moderation" field. +func (su *SettingsUpdate) SetModeration(b bool) *SettingsUpdate { + su.mutation.SetModeration(b) + return su +} + +// SetNillableModeration sets the "moderation" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableModeration(b *bool) *SettingsUpdate { + if b != nil { + su.SetModeration(*b) + } + return su +} + +// SetAutomatedmoderation sets the "automatedmoderation" field. +func (su *SettingsUpdate) SetAutomatedmoderation(b bool) *SettingsUpdate { + su.mutation.SetAutomatedmoderation(b) + return su +} + +// SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableAutomatedmoderation(b *bool) *SettingsUpdate { + if b != nil { + su.SetAutomatedmoderation(*b) + } + return su +} + +// SetTwitchannounce sets the "twitchannounce" field. +func (su *SettingsUpdate) SetTwitchannounce(b bool) *SettingsUpdate { + su.mutation.SetTwitchannounce(b) + return su +} + +// SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableTwitchannounce(b *bool) *SettingsUpdate { + if b != nil { + su.SetTwitchannounce(*b) + } + return su +} + +// SetTwitterannounce sets the "twitterannounce" field. +func (su *SettingsUpdate) SetTwitterannounce(b bool) *SettingsUpdate { + su.mutation.SetTwitterannounce(b) + return su +} + +// SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableTwitterannounce(b *bool) *SettingsUpdate { + if b != nil { + su.SetTwitterannounce(*b) + } + return su +} + +// SetMusic sets the "music" field. +func (su *SettingsUpdate) SetMusic(b bool) *SettingsUpdate { + su.mutation.SetMusic(b) + return su +} + +// SetNillableMusic sets the "music" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableMusic(b *bool) *SettingsUpdate { + if b != nil { + su.SetMusic(*b) + } + return su +} + +// SetStatspage sets the "statspage" field. +func (su *SettingsUpdate) SetStatspage(b bool) *SettingsUpdate { + su.mutation.SetStatspage(b) + return su +} + +// SetNillableStatspage sets the "statspage" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableStatspage(b *bool) *SettingsUpdate { + if b != nil { + su.SetStatspage(*b) + } + return su +} + +// SetStatsprivate sets the "statsprivate" field. +func (su *SettingsUpdate) SetStatsprivate(b bool) *SettingsUpdate { + su.mutation.SetStatsprivate(b) + return su +} + +// SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableStatsprivate(b *bool) *SettingsUpdate { + if b != nil { + su.SetStatsprivate(*b) + } + return su +} + +// SetStats sets the "stats" field. +func (su *SettingsUpdate) SetStats(b bool) *SettingsUpdate { + su.mutation.SetStats(b) + return su +} + +// SetNillableStats sets the "stats" field if the given value is not nil. +func (su *SettingsUpdate) SetNillableStats(b *bool) *SettingsUpdate { + if b != nil { + su.SetStats(*b) + } + return su +} + +// Mutation returns the SettingsMutation object of the builder. +func (su *SettingsUpdate) Mutation() *SettingsMutation { + return su.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (su *SettingsUpdate) 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.(*SettingsMutation) + 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 *SettingsUpdate) SaveX(ctx context.Context) int { + affected, err := su.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (su *SettingsUpdate) Exec(ctx context.Context) error { + _, err := su.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (su *SettingsUpdate) ExecX(ctx context.Context) { + if err := su.Exec(ctx); err != nil { + panic(err) + } +} + +func (su *SettingsUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: settings.Table, + Columns: settings.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: settings.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: settings.FieldServerid, + }) + } + if value, ok := su.mutation.Servername(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldServername, + }) + } + if value, ok := su.mutation.Ownerid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldOwnerid, + }) + } + if value, ok := su.mutation.Permtoken(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldPermtoken, + }) + } + if value, ok := su.mutation.Apitoken(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldApitoken, + }) + } + if value, ok := su.mutation.Statspagemode(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldStatspagemode, + }) + } + if value, ok := su.mutation.Loggerchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldLoggerchannel, + }) + } + if value, ok := su.mutation.Spamchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldSpamchannel, + }) + } + if value, ok := su.mutation.Greeterchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldGreeterchannel, + }) + } + if value, ok := su.mutation.Greetermode(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldGreetermode, + }) + } + if value, ok := su.mutation.Announcechannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldAnnouncechannel, + }) + } + if value, ok := su.mutation.Logger(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldLogger, + }) + } + if value, ok := su.mutation.Spamprotection(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldSpamprotection, + }) + } + if value, ok := su.mutation.Linkprotection(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldLinkprotection, + }) + } + if value, ok := su.mutation.Wordfilter(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldWordfilter, + }) + } + if value, ok := su.mutation.Greetings(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldGreetings, + }) + } + if value, ok := su.mutation.Apitoggle(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldApitoggle, + }) + } + if value, ok := su.mutation.Moderation(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldModeration, + }) + } + if value, ok := su.mutation.Automatedmoderation(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldAutomatedmoderation, + }) + } + if value, ok := su.mutation.Twitchannounce(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldTwitchannounce, + }) + } + if value, ok := su.mutation.Twitterannounce(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldTwitterannounce, + }) + } + if value, ok := su.mutation.Music(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldMusic, + }) + } + if value, ok := su.mutation.Statspage(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStatspage, + }) + } + if value, ok := su.mutation.Statsprivate(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStatsprivate, + }) + } + if value, ok := su.mutation.Stats(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStats, + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{settings.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + return n, nil +} + +// SettingsUpdateOne is the builder for updating a single Settings entity. +type SettingsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *SettingsMutation +} + +// SetServerid sets the "serverid" field. +func (suo *SettingsUpdateOne) SetServerid(s string) *SettingsUpdateOne { + suo.mutation.SetServerid(s) + return suo +} + +// SetServername sets the "servername" field. +func (suo *SettingsUpdateOne) SetServername(s string) *SettingsUpdateOne { + suo.mutation.SetServername(s) + return suo +} + +// SetOwnerid sets the "ownerid" field. +func (suo *SettingsUpdateOne) SetOwnerid(s string) *SettingsUpdateOne { + suo.mutation.SetOwnerid(s) + return suo +} + +// SetPermtoken sets the "permtoken" field. +func (suo *SettingsUpdateOne) SetPermtoken(s string) *SettingsUpdateOne { + suo.mutation.SetPermtoken(s) + return suo +} + +// SetApitoken sets the "apitoken" field. +func (suo *SettingsUpdateOne) SetApitoken(s string) *SettingsUpdateOne { + suo.mutation.SetApitoken(s) + return suo +} + +// SetStatspagemode sets the "statspagemode" field. +func (suo *SettingsUpdateOne) SetStatspagemode(s string) *SettingsUpdateOne { + suo.mutation.SetStatspagemode(s) + return suo +} + +// SetLoggerchannel sets the "loggerchannel" field. +func (suo *SettingsUpdateOne) SetLoggerchannel(s string) *SettingsUpdateOne { + suo.mutation.SetLoggerchannel(s) + return suo +} + +// SetSpamchannel sets the "spamchannel" field. +func (suo *SettingsUpdateOne) SetSpamchannel(s string) *SettingsUpdateOne { + suo.mutation.SetSpamchannel(s) + return suo +} + +// SetGreeterchannel sets the "greeterchannel" field. +func (suo *SettingsUpdateOne) SetGreeterchannel(s string) *SettingsUpdateOne { + suo.mutation.SetGreeterchannel(s) + return suo +} + +// SetGreetermode sets the "greetermode" field. +func (suo *SettingsUpdateOne) SetGreetermode(s string) *SettingsUpdateOne { + suo.mutation.SetGreetermode(s) + return suo +} + +// SetAnnouncechannel sets the "announcechannel" field. +func (suo *SettingsUpdateOne) SetAnnouncechannel(s string) *SettingsUpdateOne { + suo.mutation.SetAnnouncechannel(s) + return suo +} + +// SetLogger sets the "logger" field. +func (suo *SettingsUpdateOne) SetLogger(b bool) *SettingsUpdateOne { + suo.mutation.SetLogger(b) + return suo +} + +// SetNillableLogger sets the "logger" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableLogger(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetLogger(*b) + } + return suo +} + +// SetSpamprotection sets the "spamprotection" field. +func (suo *SettingsUpdateOne) SetSpamprotection(b bool) *SettingsUpdateOne { + suo.mutation.SetSpamprotection(b) + return suo +} + +// SetNillableSpamprotection sets the "spamprotection" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableSpamprotection(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetSpamprotection(*b) + } + return suo +} + +// SetLinkprotection sets the "linkprotection" field. +func (suo *SettingsUpdateOne) SetLinkprotection(b bool) *SettingsUpdateOne { + suo.mutation.SetLinkprotection(b) + return suo +} + +// SetNillableLinkprotection sets the "linkprotection" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableLinkprotection(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetLinkprotection(*b) + } + return suo +} + +// SetWordfilter sets the "wordfilter" field. +func (suo *SettingsUpdateOne) SetWordfilter(b bool) *SettingsUpdateOne { + suo.mutation.SetWordfilter(b) + return suo +} + +// SetNillableWordfilter sets the "wordfilter" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableWordfilter(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetWordfilter(*b) + } + return suo +} + +// SetGreetings sets the "greetings" field. +func (suo *SettingsUpdateOne) SetGreetings(b bool) *SettingsUpdateOne { + suo.mutation.SetGreetings(b) + return suo +} + +// SetNillableGreetings sets the "greetings" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableGreetings(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetGreetings(*b) + } + return suo +} + +// SetApitoggle sets the "apitoggle" field. +func (suo *SettingsUpdateOne) SetApitoggle(b bool) *SettingsUpdateOne { + suo.mutation.SetApitoggle(b) + return suo +} + +// SetNillableApitoggle sets the "apitoggle" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableApitoggle(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetApitoggle(*b) + } + return suo +} + +// SetModeration sets the "moderation" field. +func (suo *SettingsUpdateOne) SetModeration(b bool) *SettingsUpdateOne { + suo.mutation.SetModeration(b) + return suo +} + +// SetNillableModeration sets the "moderation" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableModeration(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetModeration(*b) + } + return suo +} + +// SetAutomatedmoderation sets the "automatedmoderation" field. +func (suo *SettingsUpdateOne) SetAutomatedmoderation(b bool) *SettingsUpdateOne { + suo.mutation.SetAutomatedmoderation(b) + return suo +} + +// SetNillableAutomatedmoderation sets the "automatedmoderation" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableAutomatedmoderation(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetAutomatedmoderation(*b) + } + return suo +} + +// SetTwitchannounce sets the "twitchannounce" field. +func (suo *SettingsUpdateOne) SetTwitchannounce(b bool) *SettingsUpdateOne { + suo.mutation.SetTwitchannounce(b) + return suo +} + +// SetNillableTwitchannounce sets the "twitchannounce" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableTwitchannounce(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetTwitchannounce(*b) + } + return suo +} + +// SetTwitterannounce sets the "twitterannounce" field. +func (suo *SettingsUpdateOne) SetTwitterannounce(b bool) *SettingsUpdateOne { + suo.mutation.SetTwitterannounce(b) + return suo +} + +// SetNillableTwitterannounce sets the "twitterannounce" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableTwitterannounce(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetTwitterannounce(*b) + } + return suo +} + +// SetMusic sets the "music" field. +func (suo *SettingsUpdateOne) SetMusic(b bool) *SettingsUpdateOne { + suo.mutation.SetMusic(b) + return suo +} + +// SetNillableMusic sets the "music" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableMusic(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetMusic(*b) + } + return suo +} + +// SetStatspage sets the "statspage" field. +func (suo *SettingsUpdateOne) SetStatspage(b bool) *SettingsUpdateOne { + suo.mutation.SetStatspage(b) + return suo +} + +// SetNillableStatspage sets the "statspage" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableStatspage(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetStatspage(*b) + } + return suo +} + +// SetStatsprivate sets the "statsprivate" field. +func (suo *SettingsUpdateOne) SetStatsprivate(b bool) *SettingsUpdateOne { + suo.mutation.SetStatsprivate(b) + return suo +} + +// SetNillableStatsprivate sets the "statsprivate" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableStatsprivate(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetStatsprivate(*b) + } + return suo +} + +// SetStats sets the "stats" field. +func (suo *SettingsUpdateOne) SetStats(b bool) *SettingsUpdateOne { + suo.mutation.SetStats(b) + return suo +} + +// SetNillableStats sets the "stats" field if the given value is not nil. +func (suo *SettingsUpdateOne) SetNillableStats(b *bool) *SettingsUpdateOne { + if b != nil { + suo.SetStats(*b) + } + return suo +} + +// Mutation returns the SettingsMutation object of the builder. +func (suo *SettingsUpdateOne) Mutation() *SettingsMutation { + 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 *SettingsUpdateOne) Select(field string, fields ...string) *SettingsUpdateOne { + suo.fields = append([]string{field}, fields...) + return suo +} + +// Save executes the query and returns the updated Settings entity. +func (suo *SettingsUpdateOne) Save(ctx context.Context) (*Settings, error) { + var ( + err error + node *Settings + ) + 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.(*SettingsMutation) + 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.(*Settings) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from SettingsMutation", v) + } + node = nv + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (suo *SettingsUpdateOne) SaveX(ctx context.Context) *Settings { + node, err := suo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (suo *SettingsUpdateOne) Exec(ctx context.Context) error { + _, err := suo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (suo *SettingsUpdateOne) ExecX(ctx context.Context) { + if err := suo.Exec(ctx); err != nil { + panic(err) + } +} + +func (suo *SettingsUpdateOne) sqlSave(ctx context.Context) (_node *Settings, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: settings.Table, + Columns: settings.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: settings.FieldID, + }, + }, + } + id, ok := suo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Settings.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, settings.FieldID) + for _, f := range fields { + if !settings.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != settings.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: settings.FieldServerid, + }) + } + if value, ok := suo.mutation.Servername(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldServername, + }) + } + if value, ok := suo.mutation.Ownerid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldOwnerid, + }) + } + if value, ok := suo.mutation.Permtoken(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldPermtoken, + }) + } + if value, ok := suo.mutation.Apitoken(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldApitoken, + }) + } + if value, ok := suo.mutation.Statspagemode(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldStatspagemode, + }) + } + if value, ok := suo.mutation.Loggerchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldLoggerchannel, + }) + } + if value, ok := suo.mutation.Spamchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldSpamchannel, + }) + } + if value, ok := suo.mutation.Greeterchannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldGreeterchannel, + }) + } + if value, ok := suo.mutation.Greetermode(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldGreetermode, + }) + } + if value, ok := suo.mutation.Announcechannel(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: settings.FieldAnnouncechannel, + }) + } + if value, ok := suo.mutation.Logger(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldLogger, + }) + } + if value, ok := suo.mutation.Spamprotection(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldSpamprotection, + }) + } + if value, ok := suo.mutation.Linkprotection(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldLinkprotection, + }) + } + if value, ok := suo.mutation.Wordfilter(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldWordfilter, + }) + } + if value, ok := suo.mutation.Greetings(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldGreetings, + }) + } + if value, ok := suo.mutation.Apitoggle(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldApitoggle, + }) + } + if value, ok := suo.mutation.Moderation(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldModeration, + }) + } + if value, ok := suo.mutation.Automatedmoderation(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldAutomatedmoderation, + }) + } + if value, ok := suo.mutation.Twitchannounce(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldTwitchannounce, + }) + } + if value, ok := suo.mutation.Twitterannounce(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldTwitterannounce, + }) + } + if value, ok := suo.mutation.Music(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldMusic, + }) + } + if value, ok := suo.mutation.Statspage(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStatspage, + }) + } + if value, ok := suo.mutation.Statsprivate(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStatsprivate, + }) + } + if value, ok := suo.mutation.Stats(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeBool, + Value: value, + Column: settings.FieldStats, + }) + } + _node = &Settings{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{settings.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} diff --git a/ent/socialmedia.go b/ent/socialmedia.go new file mode 100644 index 0000000..15c9b5b --- /dev/null +++ b/ent/socialmedia.go @@ -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 + } +} diff --git a/ent/socialmedia/socialmedia.go b/ent/socialmedia/socialmedia.go new file mode 100644 index 0000000..06c628a --- /dev/null +++ b/ent/socialmedia/socialmedia.go @@ -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 +} diff --git a/ent/socialmedia/where.go b/ent/socialmedia/where.go new file mode 100644 index 0000000..cd6fe23 --- /dev/null +++ b/ent/socialmedia/where.go @@ -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()) + }) +} diff --git a/ent/socialmedia_create.go b/ent/socialmedia_create.go new file mode 100644 index 0000000..b422b6e --- /dev/null +++ b/ent/socialmedia_create.go @@ -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) + } +} diff --git a/ent/socialmedia_delete.go b/ent/socialmedia_delete.go new file mode 100644 index 0000000..d54ab33 --- /dev/null +++ b/ent/socialmedia_delete.go @@ -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) +} diff --git a/ent/socialmedia_query.go b/ent/socialmedia_query.go new file mode 100644 index 0000000..f8d1f51 --- /dev/null +++ b/ent/socialmedia_query.go @@ -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) +} diff --git a/ent/socialmedia_update.go b/ent/socialmedia_update.go new file mode 100644 index 0000000..16e9a66 --- /dev/null +++ b/ent/socialmedia_update.go @@ -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 +} diff --git a/ent/support.go b/ent/support.go new file mode 100644 index 0000000..4c7269d --- /dev/null +++ b/ent/support.go @@ -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 + } +} diff --git a/ent/support/support.go b/ent/support/support.go new file mode 100644 index 0000000..dff4dd0 --- /dev/null +++ b/ent/support/support.go @@ -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 +} diff --git a/ent/support/where.go b/ent/support/where.go new file mode 100644 index 0000000..b25e8e6 --- /dev/null +++ b/ent/support/where.go @@ -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()) + }) +} diff --git a/ent/support_create.go b/ent/support_create.go new file mode 100644 index 0000000..7f80042 --- /dev/null +++ b/ent/support_create.go @@ -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) + } +} diff --git a/ent/support_delete.go b/ent/support_delete.go new file mode 100644 index 0000000..1bb332d --- /dev/null +++ b/ent/support_delete.go @@ -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) +} diff --git a/ent/support_query.go b/ent/support_query.go new file mode 100644 index 0000000..493c80a --- /dev/null +++ b/ent/support_query.go @@ -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) +} diff --git a/ent/support_update.go b/ent/support_update.go new file mode 100644 index 0000000..8de6b0e --- /dev/null +++ b/ent/support_update.go @@ -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 +} diff --git a/ent/supportresponse.go b/ent/supportresponse.go new file mode 100644 index 0000000..9664d60 --- /dev/null +++ b/ent/supportresponse.go @@ -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 + } +} diff --git a/ent/supportresponse/supportresponse.go b/ent/supportresponse/supportresponse.go new file mode 100644 index 0000000..115d97a --- /dev/null +++ b/ent/supportresponse/supportresponse.go @@ -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 +} diff --git a/ent/supportresponse/where.go b/ent/supportresponse/where.go new file mode 100644 index 0000000..a192a16 --- /dev/null +++ b/ent/supportresponse/where.go @@ -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()) + }) +} diff --git a/ent/supportresponse_create.go b/ent/supportresponse_create.go new file mode 100644 index 0000000..5607940 --- /dev/null +++ b/ent/supportresponse_create.go @@ -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) + } +} diff --git a/ent/supportresponse_delete.go b/ent/supportresponse_delete.go new file mode 100644 index 0000000..b3acab5 --- /dev/null +++ b/ent/supportresponse_delete.go @@ -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) +} diff --git a/ent/supportresponse_query.go b/ent/supportresponse_query.go new file mode 100644 index 0000000..f4547a1 --- /dev/null +++ b/ent/supportresponse_query.go @@ -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) +} diff --git a/ent/supportresponse_update.go b/ent/supportresponse_update.go new file mode 100644 index 0000000..570a20b --- /dev/null +++ b/ent/supportresponse_update.go @@ -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 +} diff --git a/ent/tx.go b/ent/tx.go new file mode 100644 index 0000000..dff0fe9 --- /dev/null +++ b/ent/tx.go @@ -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) diff --git a/ent/user.go b/ent/user.go new file mode 100644 index 0000000..cd484a3 --- /dev/null +++ b/ent/user.go @@ -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 + } +} diff --git a/ent/user/user.go b/ent/user/user.go new file mode 100644 index 0000000..a59df26 --- /dev/null +++ b/ent/user/user.go @@ -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 +) diff --git a/ent/user/where.go b/ent/user/where.go new file mode 100644 index 0000000..2b67a36 --- /dev/null +++ b/ent/user/where.go @@ -0,0 +1,799 @@ +// Code generated by ent, DO NOT EDIT. + +package user + +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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUserid), v)) + }) +} + +// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ. +func Username(v string) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldUsername), v)) + }) +} + +// Xp applies equality check predicate on the "xp" field. It's identical to XpEQ. +func Xp(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldXp), v)) + }) +} + +// Level applies equality check predicate on the "level" field. It's identical to LevelEQ. +func Level(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLevel), v)) + }) +} + +// Msgs applies equality check predicate on the "msgs" field. It's identical to MsgsEQ. +func Msgs(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMsgs), v)) + }) +} + +// Created applies equality check predicate on the "created" field. It's identical to CreatedEQ. +func Created(v time.Time) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldCreated), v)) + }) +} + +// ServeridEQ applies the EQ predicate on the "serverid" field. +func ServeridEQ(v string) predicate.User { + return predicate.User(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.User { + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldUserid), v)) + }) +} + +// UsernameEQ applies the EQ predicate on the "username" field. +func UsernameEQ(v string) predicate.User { + return predicate.User(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.User { + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldUsername), v)) + }) +} + +// XpEQ applies the EQ predicate on the "xp" field. +func XpEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldXp), v)) + }) +} + +// XpNEQ applies the NEQ predicate on the "xp" field. +func XpNEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldXp), v)) + }) +} + +// XpIn applies the In predicate on the "xp" field. +func XpIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldXp), v...)) + }) +} + +// XpNotIn applies the NotIn predicate on the "xp" field. +func XpNotIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldXp), v...)) + }) +} + +// XpGT applies the GT predicate on the "xp" field. +func XpGT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldXp), v)) + }) +} + +// XpGTE applies the GTE predicate on the "xp" field. +func XpGTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldXp), v)) + }) +} + +// XpLT applies the LT predicate on the "xp" field. +func XpLT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldXp), v)) + }) +} + +// XpLTE applies the LTE predicate on the "xp" field. +func XpLTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldXp), v)) + }) +} + +// LevelEQ applies the EQ predicate on the "level" field. +func LevelEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldLevel), v)) + }) +} + +// LevelNEQ applies the NEQ predicate on the "level" field. +func LevelNEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldLevel), v)) + }) +} + +// LevelIn applies the In predicate on the "level" field. +func LevelIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldLevel), v...)) + }) +} + +// LevelNotIn applies the NotIn predicate on the "level" field. +func LevelNotIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldLevel), v...)) + }) +} + +// LevelGT applies the GT predicate on the "level" field. +func LevelGT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldLevel), v)) + }) +} + +// LevelGTE applies the GTE predicate on the "level" field. +func LevelGTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldLevel), v)) + }) +} + +// LevelLT applies the LT predicate on the "level" field. +func LevelLT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldLevel), v)) + }) +} + +// LevelLTE applies the LTE predicate on the "level" field. +func LevelLTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldLevel), v)) + }) +} + +// MsgsEQ applies the EQ predicate on the "msgs" field. +func MsgsEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldMsgs), v)) + }) +} + +// MsgsNEQ applies the NEQ predicate on the "msgs" field. +func MsgsNEQ(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldMsgs), v)) + }) +} + +// MsgsIn applies the In predicate on the "msgs" field. +func MsgsIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldMsgs), v...)) + }) +} + +// MsgsNotIn applies the NotIn predicate on the "msgs" field. +func MsgsNotIn(vs ...int) predicate.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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(FieldMsgs), v...)) + }) +} + +// MsgsGT applies the GT predicate on the "msgs" field. +func MsgsGT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldMsgs), v)) + }) +} + +// MsgsGTE applies the GTE predicate on the "msgs" field. +func MsgsGTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldMsgs), v)) + }) +} + +// MsgsLT applies the LT predicate on the "msgs" field. +func MsgsLT(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldMsgs), v)) + }) +} + +// MsgsLTE applies the LTE predicate on the "msgs" field. +func MsgsLTE(v int) predicate.User { + return predicate.User(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldMsgs), v)) + }) +} + +// CreatedEQ applies the EQ predicate on the "created" field. +func CreatedEQ(v time.Time) predicate.User { + return predicate.User(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.User { + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User { + return predicate.User(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.User) predicate.User { + return predicate.User(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.User) predicate.User { + return predicate.User(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.User) predicate.User { + return predicate.User(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/user_create.go b/ent/user_create.go new file mode 100644 index 0000000..1ce32ff --- /dev/null +++ b/ent/user_create.go @@ -0,0 +1,383 @@ +// 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/user" +) + +// UserCreate is the builder for creating a User entity. +type UserCreate struct { + config + mutation *UserMutation + hooks []Hook +} + +// SetServerid sets the "serverid" field. +func (uc *UserCreate) SetServerid(s string) *UserCreate { + uc.mutation.SetServerid(s) + return uc +} + +// SetUserid sets the "userid" field. +func (uc *UserCreate) SetUserid(s string) *UserCreate { + uc.mutation.SetUserid(s) + return uc +} + +// SetUsername sets the "username" field. +func (uc *UserCreate) SetUsername(s string) *UserCreate { + uc.mutation.SetUsername(s) + return uc +} + +// SetXp sets the "xp" field. +func (uc *UserCreate) SetXp(i int) *UserCreate { + uc.mutation.SetXp(i) + return uc +} + +// SetNillableXp sets the "xp" field if the given value is not nil. +func (uc *UserCreate) SetNillableXp(i *int) *UserCreate { + if i != nil { + uc.SetXp(*i) + } + return uc +} + +// SetLevel sets the "level" field. +func (uc *UserCreate) SetLevel(i int) *UserCreate { + uc.mutation.SetLevel(i) + return uc +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (uc *UserCreate) SetNillableLevel(i *int) *UserCreate { + if i != nil { + uc.SetLevel(*i) + } + return uc +} + +// SetMsgs sets the "msgs" field. +func (uc *UserCreate) SetMsgs(i int) *UserCreate { + uc.mutation.SetMsgs(i) + return uc +} + +// SetNillableMsgs sets the "msgs" field if the given value is not nil. +func (uc *UserCreate) SetNillableMsgs(i *int) *UserCreate { + if i != nil { + uc.SetMsgs(*i) + } + return uc +} + +// SetCreated sets the "created" field. +func (uc *UserCreate) SetCreated(t time.Time) *UserCreate { + uc.mutation.SetCreated(t) + return uc +} + +// SetID sets the "id" field. +func (uc *UserCreate) SetID(i int) *UserCreate { + uc.mutation.SetID(i) + return uc +} + +// Mutation returns the UserMutation object of the builder. +func (uc *UserCreate) Mutation() *UserMutation { + return uc.mutation +} + +// Save creates the User in the database. +func (uc *UserCreate) Save(ctx context.Context) (*User, error) { + var ( + err error + node *User + ) + uc.defaults() + if len(uc.hooks) == 0 { + if err = uc.check(); err != nil { + return nil, err + } + node, err = uc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = uc.check(); err != nil { + return nil, err + } + uc.mutation = mutation + if node, err = uc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(uc.hooks) - 1; i >= 0; i-- { + if uc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uc.hooks[i](mut) + } + v, err := mut.Mutate(ctx, uc.mutation) + if err != nil { + return nil, err + } + nv, ok := v.(*User) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v) + } + node = nv + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (uc *UserCreate) SaveX(ctx context.Context) *User { + v, err := uc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (uc *UserCreate) Exec(ctx context.Context) error { + _, err := uc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uc *UserCreate) ExecX(ctx context.Context) { + if err := uc.Exec(ctx); err != nil { + panic(err) + } +} + +// defaults sets the default values of the builder before save. +func (uc *UserCreate) defaults() { + if _, ok := uc.mutation.Xp(); !ok { + v := user.DefaultXp + uc.mutation.SetXp(v) + } + if _, ok := uc.mutation.Level(); !ok { + v := user.DefaultLevel + uc.mutation.SetLevel(v) + } + if _, ok := uc.mutation.Msgs(); !ok { + v := user.DefaultMsgs + uc.mutation.SetMsgs(v) + } +} + +// check runs all checks and user-defined validators on the builder. +func (uc *UserCreate) check() error { + if _, ok := uc.mutation.Serverid(); !ok { + return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "User.serverid"`)} + } + if _, ok := uc.mutation.Userid(); !ok { + return &ValidationError{Name: "userid", err: errors.New(`ent: missing required field "User.userid"`)} + } + if _, ok := uc.mutation.Username(); !ok { + return &ValidationError{Name: "username", err: errors.New(`ent: missing required field "User.username"`)} + } + if _, ok := uc.mutation.Xp(); !ok { + return &ValidationError{Name: "xp", err: errors.New(`ent: missing required field "User.xp"`)} + } + if _, ok := uc.mutation.Level(); !ok { + return &ValidationError{Name: "level", err: errors.New(`ent: missing required field "User.level"`)} + } + if _, ok := uc.mutation.Msgs(); !ok { + return &ValidationError{Name: "msgs", err: errors.New(`ent: missing required field "User.msgs"`)} + } + if _, ok := uc.mutation.Created(); !ok { + return &ValidationError{Name: "created", err: errors.New(`ent: missing required field "User.created"`)} + } + return nil +} + +func (uc *UserCreate) sqlSave(ctx context.Context) (*User, error) { + _node, _spec := uc.createSpec() + if err := sqlgraph.CreateNode(ctx, uc.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 (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) { + var ( + _node = &User{config: uc.config} + _spec = &sqlgraph.CreateSpec{ + Table: user.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + } + ) + if id, ok := uc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := uc.mutation.Serverid(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldServerid, + }) + _node.Serverid = value + } + if value, ok := uc.mutation.Userid(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUserid, + }) + _node.Userid = value + } + if value, ok := uc.mutation.Username(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUsername, + }) + _node.Username = value + } + if value, ok := uc.mutation.Xp(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldXp, + }) + _node.Xp = value + } + if value, ok := uc.mutation.Level(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldLevel, + }) + _node.Level = value + } + if value, ok := uc.mutation.Msgs(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldMsgs, + }) + _node.Msgs = value + } + if value, ok := uc.mutation.Created(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: user.FieldCreated, + }) + _node.Created = value + } + return _node, _spec +} + +// UserCreateBulk is the builder for creating many User entities in bulk. +type UserCreateBulk struct { + config + builders []*UserCreate +} + +// Save creates the User entities in the database. +func (ucb *UserCreateBulk) Save(ctx context.Context) ([]*User, error) { + specs := make([]*sqlgraph.CreateSpec, len(ucb.builders)) + nodes := make([]*User, len(ucb.builders)) + mutators := make([]Mutator, len(ucb.builders)) + for i := range ucb.builders { + func(i int, root context.Context) { + builder := ucb.builders[i] + builder.defaults() + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + 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, ucb.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, ucb.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, ucb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (ucb *UserCreateBulk) SaveX(ctx context.Context) []*User { + v, err := ucb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (ucb *UserCreateBulk) Exec(ctx context.Context) error { + _, err := ucb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ucb *UserCreateBulk) ExecX(ctx context.Context) { + if err := ucb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/user_delete.go b/ent/user_delete.go new file mode 100644 index 0000000..966f3f2 --- /dev/null +++ b/ent/user_delete.go @@ -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/user" +) + +// UserDelete is the builder for deleting a User entity. +type UserDelete struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserDelete builder. +func (ud *UserDelete) Where(ps ...predicate.User) *UserDelete { + ud.mutation.Where(ps...) + return ud +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (ud *UserDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(ud.hooks) == 0 { + affected, err = ud.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + ud.mutation = mutation + affected, err = ud.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(ud.hooks) - 1; i >= 0; i-- { + if ud.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = ud.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, ud.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (ud *UserDelete) ExecX(ctx context.Context) int { + n, err := ud.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (ud *UserDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: user.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + }, + } + if ps := ud.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, ud.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return affected, err +} + +// UserDeleteOne is the builder for deleting a single User entity. +type UserDeleteOne struct { + ud *UserDelete +} + +// Exec executes the deletion query. +func (udo *UserDeleteOne) Exec(ctx context.Context) error { + n, err := udo.ud.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{user.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (udo *UserDeleteOne) ExecX(ctx context.Context) { + udo.ud.ExecX(ctx) +} diff --git a/ent/user_query.go b/ent/user_query.go new file mode 100644 index 0000000..7d05197 --- /dev/null +++ b/ent/user_query.go @@ -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/user" +) + +// UserQuery is the builder for querying User entities. +type UserQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.User + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the UserQuery builder. +func (uq *UserQuery) Where(ps ...predicate.User) *UserQuery { + uq.predicates = append(uq.predicates, ps...) + return uq +} + +// Limit adds a limit step to the query. +func (uq *UserQuery) Limit(limit int) *UserQuery { + uq.limit = &limit + return uq +} + +// Offset adds an offset step to the query. +func (uq *UserQuery) Offset(offset int) *UserQuery { + uq.offset = &offset + return uq +} + +// 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 (uq *UserQuery) Unique(unique bool) *UserQuery { + uq.unique = &unique + return uq +} + +// Order adds an order step to the query. +func (uq *UserQuery) Order(o ...OrderFunc) *UserQuery { + uq.order = append(uq.order, o...) + return uq +} + +// First returns the first User entity from the query. +// Returns a *NotFoundError when no User was found. +func (uq *UserQuery) First(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{user.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (uq *UserQuery) FirstX(ctx context.Context) *User { + node, err := uq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first User ID from the query. +// Returns a *NotFoundError when no User ID was found. +func (uq *UserQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{user.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (uq *UserQuery) FirstIDX(ctx context.Context) int { + id, err := uq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single User entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one User entity is found. +// Returns a *NotFoundError when no User entities are found. +func (uq *UserQuery) Only(ctx context.Context) (*User, error) { + nodes, err := uq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{user.Label} + default: + return nil, &NotSingularError{user.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (uq *UserQuery) OnlyX(ctx context.Context) *User { + node, err := uq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only User ID in the query. +// Returns a *NotSingularError when more than one User ID is found. +// Returns a *NotFoundError when no entities are found. +func (uq *UserQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = uq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{user.Label} + default: + err = &NotSingularError{user.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (uq *UserQuery) OnlyIDX(ctx context.Context) int { + id, err := uq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of Users. +func (uq *UserQuery) All(ctx context.Context) ([]*User, error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + return uq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (uq *UserQuery) AllX(ctx context.Context) []*User { + nodes, err := uq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of User IDs. +func (uq *UserQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := uq.Select(user.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (uq *UserQuery) IDsX(ctx context.Context) []int { + ids, err := uq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (uq *UserQuery) Count(ctx context.Context) (int, error) { + if err := uq.prepareQuery(ctx); err != nil { + return 0, err + } + return uq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (uq *UserQuery) CountX(ctx context.Context) int { + count, err := uq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (uq *UserQuery) Exist(ctx context.Context) (bool, error) { + if err := uq.prepareQuery(ctx); err != nil { + return false, err + } + return uq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (uq *UserQuery) ExistX(ctx context.Context) bool { + exist, err := uq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the UserQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (uq *UserQuery) Clone() *UserQuery { + if uq == nil { + return nil + } + return &UserQuery{ + config: uq.config, + limit: uq.limit, + offset: uq.offset, + order: append([]OrderFunc{}, uq.order...), + predicates: append([]predicate.User{}, uq.predicates...), + // clone intermediate query. + sql: uq.sql.Clone(), + path: uq.path, + unique: uq.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.User.Query(). +// GroupBy(user.FieldServerid). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (uq *UserQuery) GroupBy(field string, fields ...string) *UserGroupBy { + grbuild := &UserGroupBy{config: uq.config} + grbuild.fields = append([]string{field}, fields...) + grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := uq.prepareQuery(ctx); err != nil { + return nil, err + } + return uq.sqlQuery(ctx), nil + } + grbuild.label = user.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.User.Query(). +// Select(user.FieldServerid). +// Scan(ctx, &v) +// +func (uq *UserQuery) Select(fields ...string) *UserSelect { + uq.fields = append(uq.fields, fields...) + selbuild := &UserSelect{UserQuery: uq} + selbuild.label = user.Label + selbuild.flds, selbuild.scan = &uq.fields, selbuild.Scan + return selbuild +} + +func (uq *UserQuery) prepareQuery(ctx context.Context) error { + for _, f := range uq.fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if uq.path != nil { + prev, err := uq.path(ctx) + if err != nil { + return err + } + uq.sql = prev + } + return nil +} + +func (uq *UserQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*User, error) { + var ( + nodes = []*User{} + _spec = uq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + return (*User).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + node := &User{config: uq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, uq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (uq *UserQuery) sqlCount(ctx context.Context) (int, error) { + _spec := uq.querySpec() + _spec.Node.Columns = uq.fields + if len(uq.fields) > 0 { + _spec.Unique = uq.unique != nil && *uq.unique + } + return sqlgraph.CountNodes(ctx, uq.driver, _spec) +} + +func (uq *UserQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := uq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (uq *UserQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: user.Table, + Columns: user.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + }, + From: uq.sql, + Unique: true, + } + if unique := uq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := uq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for i := range fields { + if fields[i] != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := uq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := uq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := uq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := uq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (uq *UserQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(uq.driver.Dialect()) + t1 := builder.Table(user.Table) + columns := uq.fields + if len(columns) == 0 { + columns = user.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if uq.sql != nil { + selector = uq.sql + selector.Select(selector.Columns(columns...)...) + } + if uq.unique != nil && *uq.unique { + selector.Distinct() + } + for _, p := range uq.predicates { + p(selector) + } + for _, p := range uq.order { + p(selector) + } + if offset := uq.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 := uq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// UserGroupBy is the group-by builder for User entities. +type UserGroupBy 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 (ugb *UserGroupBy) Aggregate(fns ...AggregateFunc) *UserGroupBy { + ugb.fns = append(ugb.fns, fns...) + return ugb +} + +// Scan applies the group-by query and scans the result into the given value. +func (ugb *UserGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := ugb.path(ctx) + if err != nil { + return err + } + ugb.sql = query + return ugb.sqlScan(ctx, v) +} + +func (ugb *UserGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range ugb.fields { + if !user.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := ugb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := ugb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (ugb *UserGroupBy) sqlQuery() *sql.Selector { + selector := ugb.sql.Select() + aggregation := make([]string, 0, len(ugb.fns)) + for _, fn := range ugb.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(ugb.fields)+len(ugb.fns)) + for _, f := range ugb.fields { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(ugb.fields...)...) +} + +// UserSelect is the builder for selecting fields of User entities. +type UserSelect struct { + *UserQuery + selector + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (us *UserSelect) Scan(ctx context.Context, v interface{}) error { + if err := us.prepareQuery(ctx); err != nil { + return err + } + us.sql = us.UserQuery.sqlQuery(ctx) + return us.sqlScan(ctx, v) +} + +func (us *UserSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := us.sql.Query() + if err := us.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/user_update.go b/ent/user_update.go new file mode 100644 index 0000000..d840510 --- /dev/null +++ b/ent/user_update.go @@ -0,0 +1,560 @@ +// 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/user" +) + +// UserUpdate is the builder for updating User entities. +type UserUpdate struct { + config + hooks []Hook + mutation *UserMutation +} + +// Where appends a list predicates to the UserUpdate builder. +func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate { + uu.mutation.Where(ps...) + return uu +} + +// SetServerid sets the "serverid" field. +func (uu *UserUpdate) SetServerid(s string) *UserUpdate { + uu.mutation.SetServerid(s) + return uu +} + +// SetUserid sets the "userid" field. +func (uu *UserUpdate) SetUserid(s string) *UserUpdate { + uu.mutation.SetUserid(s) + return uu +} + +// SetUsername sets the "username" field. +func (uu *UserUpdate) SetUsername(s string) *UserUpdate { + uu.mutation.SetUsername(s) + return uu +} + +// SetXp sets the "xp" field. +func (uu *UserUpdate) SetXp(i int) *UserUpdate { + uu.mutation.ResetXp() + uu.mutation.SetXp(i) + return uu +} + +// SetNillableXp sets the "xp" field if the given value is not nil. +func (uu *UserUpdate) SetNillableXp(i *int) *UserUpdate { + if i != nil { + uu.SetXp(*i) + } + return uu +} + +// AddXp adds i to the "xp" field. +func (uu *UserUpdate) AddXp(i int) *UserUpdate { + uu.mutation.AddXp(i) + return uu +} + +// SetLevel sets the "level" field. +func (uu *UserUpdate) SetLevel(i int) *UserUpdate { + uu.mutation.ResetLevel() + uu.mutation.SetLevel(i) + return uu +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (uu *UserUpdate) SetNillableLevel(i *int) *UserUpdate { + if i != nil { + uu.SetLevel(*i) + } + return uu +} + +// AddLevel adds i to the "level" field. +func (uu *UserUpdate) AddLevel(i int) *UserUpdate { + uu.mutation.AddLevel(i) + return uu +} + +// SetMsgs sets the "msgs" field. +func (uu *UserUpdate) SetMsgs(i int) *UserUpdate { + uu.mutation.ResetMsgs() + uu.mutation.SetMsgs(i) + return uu +} + +// SetNillableMsgs sets the "msgs" field if the given value is not nil. +func (uu *UserUpdate) SetNillableMsgs(i *int) *UserUpdate { + if i != nil { + uu.SetMsgs(*i) + } + return uu +} + +// AddMsgs adds i to the "msgs" field. +func (uu *UserUpdate) AddMsgs(i int) *UserUpdate { + uu.mutation.AddMsgs(i) + return uu +} + +// SetCreated sets the "created" field. +func (uu *UserUpdate) SetCreated(t time.Time) *UserUpdate { + uu.mutation.SetCreated(t) + return uu +} + +// Mutation returns the UserMutation object of the builder. +func (uu *UserUpdate) Mutation() *UserMutation { + return uu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (uu *UserUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(uu.hooks) == 0 { + affected, err = uu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + uu.mutation = mutation + affected, err = uu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(uu.hooks) - 1; i >= 0; i-- { + if uu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, uu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (uu *UserUpdate) SaveX(ctx context.Context) int { + affected, err := uu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (uu *UserUpdate) Exec(ctx context.Context) error { + _, err := uu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uu *UserUpdate) ExecX(ctx context.Context) { + if err := uu.Exec(ctx); err != nil { + panic(err) + } +} + +func (uu *UserUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: user.Table, + Columns: user.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + }, + } + if ps := uu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uu.mutation.Serverid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldServerid, + }) + } + if value, ok := uu.mutation.Userid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUserid, + }) + } + if value, ok := uu.mutation.Username(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUsername, + }) + } + if value, ok := uu.mutation.Xp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldXp, + }) + } + if value, ok := uu.mutation.AddedXp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldXp, + }) + } + if value, ok := uu.mutation.Level(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldLevel, + }) + } + if value, ok := uu.mutation.AddedLevel(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldLevel, + }) + } + if value, ok := uu.mutation.Msgs(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldMsgs, + }) + } + if value, ok := uu.mutation.AddedMsgs(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldMsgs, + }) + } + if value, ok := uu.mutation.Created(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: user.FieldCreated, + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, uu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + return n, nil +} + +// UserUpdateOne is the builder for updating a single User entity. +type UserUpdateOne struct { + config + fields []string + hooks []Hook + mutation *UserMutation +} + +// SetServerid sets the "serverid" field. +func (uuo *UserUpdateOne) SetServerid(s string) *UserUpdateOne { + uuo.mutation.SetServerid(s) + return uuo +} + +// SetUserid sets the "userid" field. +func (uuo *UserUpdateOne) SetUserid(s string) *UserUpdateOne { + uuo.mutation.SetUserid(s) + return uuo +} + +// SetUsername sets the "username" field. +func (uuo *UserUpdateOne) SetUsername(s string) *UserUpdateOne { + uuo.mutation.SetUsername(s) + return uuo +} + +// SetXp sets the "xp" field. +func (uuo *UserUpdateOne) SetXp(i int) *UserUpdateOne { + uuo.mutation.ResetXp() + uuo.mutation.SetXp(i) + return uuo +} + +// SetNillableXp sets the "xp" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableXp(i *int) *UserUpdateOne { + if i != nil { + uuo.SetXp(*i) + } + return uuo +} + +// AddXp adds i to the "xp" field. +func (uuo *UserUpdateOne) AddXp(i int) *UserUpdateOne { + uuo.mutation.AddXp(i) + return uuo +} + +// SetLevel sets the "level" field. +func (uuo *UserUpdateOne) SetLevel(i int) *UserUpdateOne { + uuo.mutation.ResetLevel() + uuo.mutation.SetLevel(i) + return uuo +} + +// SetNillableLevel sets the "level" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableLevel(i *int) *UserUpdateOne { + if i != nil { + uuo.SetLevel(*i) + } + return uuo +} + +// AddLevel adds i to the "level" field. +func (uuo *UserUpdateOne) AddLevel(i int) *UserUpdateOne { + uuo.mutation.AddLevel(i) + return uuo +} + +// SetMsgs sets the "msgs" field. +func (uuo *UserUpdateOne) SetMsgs(i int) *UserUpdateOne { + uuo.mutation.ResetMsgs() + uuo.mutation.SetMsgs(i) + return uuo +} + +// SetNillableMsgs sets the "msgs" field if the given value is not nil. +func (uuo *UserUpdateOne) SetNillableMsgs(i *int) *UserUpdateOne { + if i != nil { + uuo.SetMsgs(*i) + } + return uuo +} + +// AddMsgs adds i to the "msgs" field. +func (uuo *UserUpdateOne) AddMsgs(i int) *UserUpdateOne { + uuo.mutation.AddMsgs(i) + return uuo +} + +// SetCreated sets the "created" field. +func (uuo *UserUpdateOne) SetCreated(t time.Time) *UserUpdateOne { + uuo.mutation.SetCreated(t) + return uuo +} + +// Mutation returns the UserMutation object of the builder. +func (uuo *UserUpdateOne) Mutation() *UserMutation { + return uuo.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 (uuo *UserUpdateOne) Select(field string, fields ...string) *UserUpdateOne { + uuo.fields = append([]string{field}, fields...) + return uuo +} + +// Save executes the query and returns the updated User entity. +func (uuo *UserUpdateOne) Save(ctx context.Context) (*User, error) { + var ( + err error + node *User + ) + if len(uuo.hooks) == 0 { + node, err = uuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*UserMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + uuo.mutation = mutation + node, err = uuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(uuo.hooks) - 1; i >= 0; i-- { + if uuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = uuo.hooks[i](mut) + } + v, err := mut.Mutate(ctx, uuo.mutation) + if err != nil { + return nil, err + } + nv, ok := v.(*User) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from UserMutation", v) + } + node = nv + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (uuo *UserUpdateOne) SaveX(ctx context.Context) *User { + node, err := uuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (uuo *UserUpdateOne) Exec(ctx context.Context) error { + _, err := uuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (uuo *UserUpdateOne) ExecX(ctx context.Context) { + if err := uuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (uuo *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: user.Table, + Columns: user.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: user.FieldID, + }, + }, + } + id, ok := uuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "User.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := uuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, user.FieldID) + for _, f := range fields { + if !user.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != user.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := uuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := uuo.mutation.Serverid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldServerid, + }) + } + if value, ok := uuo.mutation.Userid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUserid, + }) + } + if value, ok := uuo.mutation.Username(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: user.FieldUsername, + }) + } + if value, ok := uuo.mutation.Xp(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldXp, + }) + } + if value, ok := uuo.mutation.AddedXp(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldXp, + }) + } + if value, ok := uuo.mutation.Level(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldLevel, + }) + } + if value, ok := uuo.mutation.AddedLevel(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldLevel, + }) + } + if value, ok := uuo.mutation.Msgs(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldMsgs, + }) + } + if value, ok := uuo.mutation.AddedMsgs(); ok { + _spec.Fields.Add = append(_spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Value: value, + Column: user.FieldMsgs, + }) + } + if value, ok := uuo.mutation.Created(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeTime, + Value: value, + Column: user.FieldCreated, + }) + } + _node = &User{config: uuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, uuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{user.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} diff --git a/ent/warns.go b/ent/warns.go new file mode 100644 index 0000000..c325c9c --- /dev/null +++ b/ent/warns.go @@ -0,0 +1,165 @@ +// Code generated by ent, DO NOT EDIT. + +package ent + +import ( + "fmt" + "strings" + + "entgo.io/ent/dialect/sql" + "github.com/FrankenBotDev/FrankenAPI/ent/warns" +) + +// Warns is the model entity for the Warns schema. +type Warns struct { + config `json:"-"` + // ID of the ent. + ID int `json:"id,omitempty"` + // Emitter holds the value of the "emitter" field. + Emitter string `json:"emitter,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"` + // Refid holds the value of the "refid" field. + Refid string `json:"refid,omitempty"` +} + +// scanValues returns the types for scanning values from sql.Rows. +func (*Warns) scanValues(columns []string) ([]interface{}, error) { + values := make([]interface{}, len(columns)) + for i := range columns { + switch columns[i] { + case warns.FieldID: + values[i] = new(sql.NullInt64) + case warns.FieldEmitter, warns.FieldServerid, warns.FieldTarget, warns.FieldType, warns.FieldDuration, warns.FieldReason, warns.FieldRefid: + values[i] = new(sql.NullString) + default: + return nil, fmt.Errorf("unexpected column %q for type Warns", columns[i]) + } + } + return values, nil +} + +// assignValues assigns the values that were returned from sql.Rows (after scanning) +// to the Warns fields. +func (w *Warns) 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 warns.FieldID: + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) + } + w.ID = int(value.Int64) + case warns.FieldEmitter: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field emitter", values[i]) + } else if value.Valid { + w.Emitter = value.String + } + case warns.FieldServerid: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field serverid", values[i]) + } else if value.Valid { + w.Serverid = value.String + } + case warns.FieldTarget: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field target", values[i]) + } else if value.Valid { + w.Target = value.String + } + case warns.FieldType: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field type", values[i]) + } else if value.Valid { + w.Type = value.String + } + case warns.FieldDuration: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field duration", values[i]) + } else if value.Valid { + w.Duration = value.String + } + case warns.FieldReason: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field reason", values[i]) + } else if value.Valid { + w.Reason = value.String + } + case warns.FieldRefid: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field refid", values[i]) + } else if value.Valid { + w.Refid = value.String + } + } + } + return nil +} + +// Update returns a builder for updating this Warns. +// Note that you need to call Warns.Unwrap() before calling this method if this Warns +// was returned from a transaction, and the transaction was committed or rolled back. +func (w *Warns) Update() *WarnsUpdateOne { + return (&WarnsClient{config: w.config}).UpdateOne(w) +} + +// Unwrap unwraps the Warns 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 (w *Warns) Unwrap() *Warns { + _tx, ok := w.config.driver.(*txDriver) + if !ok { + panic("ent: Warns is not a transactional entity") + } + w.config.driver = _tx.drv + return w +} + +// String implements the fmt.Stringer. +func (w *Warns) String() string { + var builder strings.Builder + builder.WriteString("Warns(") + builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) + builder.WriteString("emitter=") + builder.WriteString(w.Emitter) + builder.WriteString(", ") + builder.WriteString("serverid=") + builder.WriteString(w.Serverid) + builder.WriteString(", ") + builder.WriteString("target=") + builder.WriteString(w.Target) + builder.WriteString(", ") + builder.WriteString("type=") + builder.WriteString(w.Type) + builder.WriteString(", ") + builder.WriteString("duration=") + builder.WriteString(w.Duration) + builder.WriteString(", ") + builder.WriteString("reason=") + builder.WriteString(w.Reason) + builder.WriteString(", ") + builder.WriteString("refid=") + builder.WriteString(w.Refid) + builder.WriteByte(')') + return builder.String() +} + +// WarnsSlice is a parsable slice of Warns. +type WarnsSlice []*Warns + +func (w WarnsSlice) config(cfg config) { + for _i := range w { + w[_i].config = cfg + } +} diff --git a/ent/warns/warns.go b/ent/warns/warns.go new file mode 100644 index 0000000..ba68834 --- /dev/null +++ b/ent/warns/warns.go @@ -0,0 +1,48 @@ +// Code generated by ent, DO NOT EDIT. + +package warns + +const ( + // Label holds the string label denoting the warns type in the database. + Label = "warns" + // FieldID holds the string denoting the id field in the database. + FieldID = "id" + // FieldEmitter holds the string denoting the emitter field in the database. + FieldEmitter = "emitter" + // 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" + // FieldRefid holds the string denoting the refid field in the database. + FieldRefid = "refid" + // Table holds the table name of the warns in the database. + Table = "warns" +) + +// Columns holds all SQL columns for warns fields. +var Columns = []string{ + FieldID, + FieldEmitter, + FieldServerid, + FieldTarget, + FieldType, + FieldDuration, + FieldReason, + FieldRefid, +} + +// 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 +} diff --git a/ent/warns/where.go b/ent/warns/where.go new file mode 100644 index 0000000..7e77982 --- /dev/null +++ b/ent/warns/where.go @@ -0,0 +1,937 @@ +// Code generated by ent, DO NOT EDIT. + +package warns + +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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldID), id)) + }) +} + +// Emitter applies equality check predicate on the "emitter" field. It's identical to EmitterEQ. +func Emitter(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldEmitter), v)) + }) +} + +// Serverid applies equality check predicate on the "serverid" field. It's identical to ServeridEQ. +func Serverid(v string) predicate.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldReason), v)) + }) +} + +// Refid applies equality check predicate on the "refid" field. It's identical to RefidEQ. +func Refid(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldRefid), v)) + }) +} + +// EmitterEQ applies the EQ predicate on the "emitter" field. +func EmitterEQ(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldEmitter), v)) + }) +} + +// EmitterNEQ applies the NEQ predicate on the "emitter" field. +func EmitterNEQ(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldEmitter), v)) + }) +} + +// EmitterIn applies the In predicate on the "emitter" field. +func EmitterIn(vs ...string) predicate.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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(FieldEmitter), v...)) + }) +} + +// EmitterNotIn applies the NotIn predicate on the "emitter" field. +func EmitterNotIn(vs ...string) predicate.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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(FieldEmitter), v...)) + }) +} + +// EmitterGT applies the GT predicate on the "emitter" field. +func EmitterGT(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldEmitter), v)) + }) +} + +// EmitterGTE applies the GTE predicate on the "emitter" field. +func EmitterGTE(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldEmitter), v)) + }) +} + +// EmitterLT applies the LT predicate on the "emitter" field. +func EmitterLT(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldEmitter), v)) + }) +} + +// EmitterLTE applies the LTE predicate on the "emitter" field. +func EmitterLTE(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldEmitter), v)) + }) +} + +// EmitterContains applies the Contains predicate on the "emitter" field. +func EmitterContains(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.Contains(s.C(FieldEmitter), v)) + }) +} + +// EmitterHasPrefix applies the HasPrefix predicate on the "emitter" field. +func EmitterHasPrefix(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.HasPrefix(s.C(FieldEmitter), v)) + }) +} + +// EmitterHasSuffix applies the HasSuffix predicate on the "emitter" field. +func EmitterHasSuffix(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.HasSuffix(s.C(FieldEmitter), v)) + }) +} + +// EmitterEqualFold applies the EqualFold predicate on the "emitter" field. +func EmitterEqualFold(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.EqualFold(s.C(FieldEmitter), v)) + }) +} + +// EmitterContainsFold applies the ContainsFold predicate on the "emitter" field. +func EmitterContainsFold(v string) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldEmitter), v)) + }) +} + +// ServeridEQ applies the EQ predicate on the "serverid" field. +func ServeridEQ(v string) predicate.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldReason), v)) + }) +} + +// RefidEQ applies the EQ predicate on the "refid" field. +func RefidEQ(v string) predicate.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(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.Warns { + return predicate.Warns(func(s *sql.Selector) { + s.Where(sql.ContainsFold(s.C(FieldRefid), v)) + }) +} + +// And groups predicates with the AND operator between them. +func And(predicates ...predicate.Warns) predicate.Warns { + return predicate.Warns(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.Warns) predicate.Warns { + return predicate.Warns(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.Warns) predicate.Warns { + return predicate.Warns(func(s *sql.Selector) { + p(s.Not()) + }) +} diff --git a/ent/warns_create.go b/ent/warns_create.go new file mode 100644 index 0000000..f5dfc52 --- /dev/null +++ b/ent/warns_create.go @@ -0,0 +1,340 @@ +// 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/warns" +) + +// WarnsCreate is the builder for creating a Warns entity. +type WarnsCreate struct { + config + mutation *WarnsMutation + hooks []Hook +} + +// SetEmitter sets the "emitter" field. +func (wc *WarnsCreate) SetEmitter(s string) *WarnsCreate { + wc.mutation.SetEmitter(s) + return wc +} + +// SetServerid sets the "serverid" field. +func (wc *WarnsCreate) SetServerid(s string) *WarnsCreate { + wc.mutation.SetServerid(s) + return wc +} + +// SetTarget sets the "target" field. +func (wc *WarnsCreate) SetTarget(s string) *WarnsCreate { + wc.mutation.SetTarget(s) + return wc +} + +// SetType sets the "type" field. +func (wc *WarnsCreate) SetType(s string) *WarnsCreate { + wc.mutation.SetType(s) + return wc +} + +// SetDuration sets the "duration" field. +func (wc *WarnsCreate) SetDuration(s string) *WarnsCreate { + wc.mutation.SetDuration(s) + return wc +} + +// SetReason sets the "reason" field. +func (wc *WarnsCreate) SetReason(s string) *WarnsCreate { + wc.mutation.SetReason(s) + return wc +} + +// SetRefid sets the "refid" field. +func (wc *WarnsCreate) SetRefid(s string) *WarnsCreate { + wc.mutation.SetRefid(s) + return wc +} + +// SetID sets the "id" field. +func (wc *WarnsCreate) SetID(i int) *WarnsCreate { + wc.mutation.SetID(i) + return wc +} + +// Mutation returns the WarnsMutation object of the builder. +func (wc *WarnsCreate) Mutation() *WarnsMutation { + return wc.mutation +} + +// Save creates the Warns in the database. +func (wc *WarnsCreate) Save(ctx context.Context) (*Warns, error) { + var ( + err error + node *Warns + ) + if len(wc.hooks) == 0 { + if err = wc.check(); err != nil { + return nil, err + } + node, err = wc.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WarnsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + if err = wc.check(); err != nil { + return nil, err + } + wc.mutation = mutation + if node, err = wc.sqlSave(ctx); err != nil { + return nil, err + } + mutation.id = &node.ID + mutation.done = true + return node, err + }) + for i := len(wc.hooks) - 1; i >= 0; i-- { + if wc.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wc.hooks[i](mut) + } + v, err := mut.Mutate(ctx, wc.mutation) + if err != nil { + return nil, err + } + nv, ok := v.(*Warns) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from WarnsMutation", v) + } + node = nv + } + return node, err +} + +// SaveX calls Save and panics if Save returns an error. +func (wc *WarnsCreate) SaveX(ctx context.Context) *Warns { + v, err := wc.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wc *WarnsCreate) Exec(ctx context.Context) error { + _, err := wc.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wc *WarnsCreate) ExecX(ctx context.Context) { + if err := wc.Exec(ctx); err != nil { + panic(err) + } +} + +// check runs all checks and user-defined validators on the builder. +func (wc *WarnsCreate) check() error { + if _, ok := wc.mutation.Emitter(); !ok { + return &ValidationError{Name: "emitter", err: errors.New(`ent: missing required field "Warns.emitter"`)} + } + if _, ok := wc.mutation.Serverid(); !ok { + return &ValidationError{Name: "serverid", err: errors.New(`ent: missing required field "Warns.serverid"`)} + } + if _, ok := wc.mutation.Target(); !ok { + return &ValidationError{Name: "target", err: errors.New(`ent: missing required field "Warns.target"`)} + } + if _, ok := wc.mutation.GetType(); !ok { + return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "Warns.type"`)} + } + if _, ok := wc.mutation.Duration(); !ok { + return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Warns.duration"`)} + } + if _, ok := wc.mutation.Reason(); !ok { + return &ValidationError{Name: "reason", err: errors.New(`ent: missing required field "Warns.reason"`)} + } + if _, ok := wc.mutation.Refid(); !ok { + return &ValidationError{Name: "refid", err: errors.New(`ent: missing required field "Warns.refid"`)} + } + return nil +} + +func (wc *WarnsCreate) sqlSave(ctx context.Context) (*Warns, error) { + _node, _spec := wc.createSpec() + if err := sqlgraph.CreateNode(ctx, wc.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 (wc *WarnsCreate) createSpec() (*Warns, *sqlgraph.CreateSpec) { + var ( + _node = &Warns{config: wc.config} + _spec = &sqlgraph.CreateSpec{ + Table: warns.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: warns.FieldID, + }, + } + ) + if id, ok := wc.mutation.ID(); ok { + _node.ID = id + _spec.ID.Value = id + } + if value, ok := wc.mutation.Emitter(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldEmitter, + }) + _node.Emitter = value + } + if value, ok := wc.mutation.Serverid(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldServerid, + }) + _node.Serverid = value + } + if value, ok := wc.mutation.Target(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldTarget, + }) + _node.Target = value + } + if value, ok := wc.mutation.GetType(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldType, + }) + _node.Type = value + } + if value, ok := wc.mutation.Duration(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldDuration, + }) + _node.Duration = value + } + if value, ok := wc.mutation.Reason(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldReason, + }) + _node.Reason = value + } + if value, ok := wc.mutation.Refid(); ok { + _spec.Fields = append(_spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldRefid, + }) + _node.Refid = value + } + return _node, _spec +} + +// WarnsCreateBulk is the builder for creating many Warns entities in bulk. +type WarnsCreateBulk struct { + config + builders []*WarnsCreate +} + +// Save creates the Warns entities in the database. +func (wcb *WarnsCreateBulk) Save(ctx context.Context) ([]*Warns, error) { + specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) + nodes := make([]*Warns, len(wcb.builders)) + mutators := make([]Mutator, len(wcb.builders)) + for i := range wcb.builders { + func(i int, root context.Context) { + builder := wcb.builders[i] + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WarnsMutation) + 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, wcb.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, wcb.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, wcb.builders[0].mutation); err != nil { + return nil, err + } + } + return nodes, nil +} + +// SaveX is like Save, but panics if an error occurs. +func (wcb *WarnsCreateBulk) SaveX(ctx context.Context) []*Warns { + v, err := wcb.Save(ctx) + if err != nil { + panic(err) + } + return v +} + +// Exec executes the query. +func (wcb *WarnsCreateBulk) Exec(ctx context.Context) error { + _, err := wcb.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wcb *WarnsCreateBulk) ExecX(ctx context.Context) { + if err := wcb.Exec(ctx); err != nil { + panic(err) + } +} diff --git a/ent/warns_delete.go b/ent/warns_delete.go new file mode 100644 index 0000000..c1baf40 --- /dev/null +++ b/ent/warns_delete.go @@ -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/warns" +) + +// WarnsDelete is the builder for deleting a Warns entity. +type WarnsDelete struct { + config + hooks []Hook + mutation *WarnsMutation +} + +// Where appends a list predicates to the WarnsDelete builder. +func (wd *WarnsDelete) Where(ps ...predicate.Warns) *WarnsDelete { + wd.mutation.Where(ps...) + return wd +} + +// Exec executes the deletion query and returns how many vertices were deleted. +func (wd *WarnsDelete) Exec(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(wd.hooks) == 0 { + affected, err = wd.sqlExec(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WarnsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wd.mutation = mutation + affected, err = wd.sqlExec(ctx) + mutation.done = true + return affected, err + }) + for i := len(wd.hooks) - 1; i >= 0; i-- { + if wd.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wd.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wd.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wd *WarnsDelete) ExecX(ctx context.Context) int { + n, err := wd.Exec(ctx) + if err != nil { + panic(err) + } + return n +} + +func (wd *WarnsDelete) sqlExec(ctx context.Context) (int, error) { + _spec := &sqlgraph.DeleteSpec{ + Node: &sqlgraph.NodeSpec{ + Table: warns.Table, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: warns.FieldID, + }, + }, + } + if ps := wd.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec) + if err != nil && sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return affected, err +} + +// WarnsDeleteOne is the builder for deleting a single Warns entity. +type WarnsDeleteOne struct { + wd *WarnsDelete +} + +// Exec executes the deletion query. +func (wdo *WarnsDeleteOne) Exec(ctx context.Context) error { + n, err := wdo.wd.Exec(ctx) + switch { + case err != nil: + return err + case n == 0: + return &NotFoundError{warns.Label} + default: + return nil + } +} + +// ExecX is like Exec, but panics if an error occurs. +func (wdo *WarnsDeleteOne) ExecX(ctx context.Context) { + wdo.wd.ExecX(ctx) +} diff --git a/ent/warns_query.go b/ent/warns_query.go new file mode 100644 index 0000000..ab0c2e3 --- /dev/null +++ b/ent/warns_query.go @@ -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/warns" +) + +// WarnsQuery is the builder for querying Warns entities. +type WarnsQuery struct { + config + limit *int + offset *int + unique *bool + order []OrderFunc + fields []string + predicates []predicate.Warns + // intermediate query (i.e. traversal path). + sql *sql.Selector + path func(context.Context) (*sql.Selector, error) +} + +// Where adds a new predicate for the WarnsQuery builder. +func (wq *WarnsQuery) Where(ps ...predicate.Warns) *WarnsQuery { + wq.predicates = append(wq.predicates, ps...) + return wq +} + +// Limit adds a limit step to the query. +func (wq *WarnsQuery) Limit(limit int) *WarnsQuery { + wq.limit = &limit + return wq +} + +// Offset adds an offset step to the query. +func (wq *WarnsQuery) Offset(offset int) *WarnsQuery { + wq.offset = &offset + return wq +} + +// 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 (wq *WarnsQuery) Unique(unique bool) *WarnsQuery { + wq.unique = &unique + return wq +} + +// Order adds an order step to the query. +func (wq *WarnsQuery) Order(o ...OrderFunc) *WarnsQuery { + wq.order = append(wq.order, o...) + return wq +} + +// First returns the first Warns entity from the query. +// Returns a *NotFoundError when no Warns was found. +func (wq *WarnsQuery) First(ctx context.Context) (*Warns, error) { + nodes, err := wq.Limit(1).All(ctx) + if err != nil { + return nil, err + } + if len(nodes) == 0 { + return nil, &NotFoundError{warns.Label} + } + return nodes[0], nil +} + +// FirstX is like First, but panics if an error occurs. +func (wq *WarnsQuery) FirstX(ctx context.Context) *Warns { + node, err := wq.First(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return node +} + +// FirstID returns the first Warns ID from the query. +// Returns a *NotFoundError when no Warns ID was found. +func (wq *WarnsQuery) FirstID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(1).IDs(ctx); err != nil { + return + } + if len(ids) == 0 { + err = &NotFoundError{warns.Label} + return + } + return ids[0], nil +} + +// FirstIDX is like FirstID, but panics if an error occurs. +func (wq *WarnsQuery) FirstIDX(ctx context.Context) int { + id, err := wq.FirstID(ctx) + if err != nil && !IsNotFound(err) { + panic(err) + } + return id +} + +// Only returns a single Warns entity found by the query, ensuring it only returns one. +// Returns a *NotSingularError when more than one Warns entity is found. +// Returns a *NotFoundError when no Warns entities are found. +func (wq *WarnsQuery) Only(ctx context.Context) (*Warns, error) { + nodes, err := wq.Limit(2).All(ctx) + if err != nil { + return nil, err + } + switch len(nodes) { + case 1: + return nodes[0], nil + case 0: + return nil, &NotFoundError{warns.Label} + default: + return nil, &NotSingularError{warns.Label} + } +} + +// OnlyX is like Only, but panics if an error occurs. +func (wq *WarnsQuery) OnlyX(ctx context.Context) *Warns { + node, err := wq.Only(ctx) + if err != nil { + panic(err) + } + return node +} + +// OnlyID is like Only, but returns the only Warns ID in the query. +// Returns a *NotSingularError when more than one Warns ID is found. +// Returns a *NotFoundError when no entities are found. +func (wq *WarnsQuery) OnlyID(ctx context.Context) (id int, err error) { + var ids []int + if ids, err = wq.Limit(2).IDs(ctx); err != nil { + return + } + switch len(ids) { + case 1: + id = ids[0] + case 0: + err = &NotFoundError{warns.Label} + default: + err = &NotSingularError{warns.Label} + } + return +} + +// OnlyIDX is like OnlyID, but panics if an error occurs. +func (wq *WarnsQuery) OnlyIDX(ctx context.Context) int { + id, err := wq.OnlyID(ctx) + if err != nil { + panic(err) + } + return id +} + +// All executes the query and returns a list of WarnsSlice. +func (wq *WarnsQuery) All(ctx context.Context) ([]*Warns, error) { + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + return wq.sqlAll(ctx) +} + +// AllX is like All, but panics if an error occurs. +func (wq *WarnsQuery) AllX(ctx context.Context) []*Warns { + nodes, err := wq.All(ctx) + if err != nil { + panic(err) + } + return nodes +} + +// IDs executes the query and returns a list of Warns IDs. +func (wq *WarnsQuery) IDs(ctx context.Context) ([]int, error) { + var ids []int + if err := wq.Select(warns.FieldID).Scan(ctx, &ids); err != nil { + return nil, err + } + return ids, nil +} + +// IDsX is like IDs, but panics if an error occurs. +func (wq *WarnsQuery) IDsX(ctx context.Context) []int { + ids, err := wq.IDs(ctx) + if err != nil { + panic(err) + } + return ids +} + +// Count returns the count of the given query. +func (wq *WarnsQuery) Count(ctx context.Context) (int, error) { + if err := wq.prepareQuery(ctx); err != nil { + return 0, err + } + return wq.sqlCount(ctx) +} + +// CountX is like Count, but panics if an error occurs. +func (wq *WarnsQuery) CountX(ctx context.Context) int { + count, err := wq.Count(ctx) + if err != nil { + panic(err) + } + return count +} + +// Exist returns true if the query has elements in the graph. +func (wq *WarnsQuery) Exist(ctx context.Context) (bool, error) { + if err := wq.prepareQuery(ctx); err != nil { + return false, err + } + return wq.sqlExist(ctx) +} + +// ExistX is like Exist, but panics if an error occurs. +func (wq *WarnsQuery) ExistX(ctx context.Context) bool { + exist, err := wq.Exist(ctx) + if err != nil { + panic(err) + } + return exist +} + +// Clone returns a duplicate of the WarnsQuery builder, including all associated steps. It can be +// used to prepare common query builders and use them differently after the clone is made. +func (wq *WarnsQuery) Clone() *WarnsQuery { + if wq == nil { + return nil + } + return &WarnsQuery{ + config: wq.config, + limit: wq.limit, + offset: wq.offset, + order: append([]OrderFunc{}, wq.order...), + predicates: append([]predicate.Warns{}, wq.predicates...), + // clone intermediate query. + sql: wq.sql.Clone(), + path: wq.path, + unique: wq.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 { +// Emitter string `json:"emitter,omitempty"` +// Count int `json:"count,omitempty"` +// } +// +// client.Warns.Query(). +// GroupBy(warns.FieldEmitter). +// Aggregate(ent.Count()). +// Scan(ctx, &v) +// +func (wq *WarnsQuery) GroupBy(field string, fields ...string) *WarnsGroupBy { + grbuild := &WarnsGroupBy{config: wq.config} + grbuild.fields = append([]string{field}, fields...) + grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { + if err := wq.prepareQuery(ctx); err != nil { + return nil, err + } + return wq.sqlQuery(ctx), nil + } + grbuild.label = warns.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 { +// Emitter string `json:"emitter,omitempty"` +// } +// +// client.Warns.Query(). +// Select(warns.FieldEmitter). +// Scan(ctx, &v) +// +func (wq *WarnsQuery) Select(fields ...string) *WarnsSelect { + wq.fields = append(wq.fields, fields...) + selbuild := &WarnsSelect{WarnsQuery: wq} + selbuild.label = warns.Label + selbuild.flds, selbuild.scan = &wq.fields, selbuild.Scan + return selbuild +} + +func (wq *WarnsQuery) prepareQuery(ctx context.Context) error { + for _, f := range wq.fields { + if !warns.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + } + if wq.path != nil { + prev, err := wq.path(ctx) + if err != nil { + return err + } + wq.sql = prev + } + return nil +} + +func (wq *WarnsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Warns, error) { + var ( + nodes = []*Warns{} + _spec = wq.querySpec() + ) + _spec.ScanValues = func(columns []string) ([]interface{}, error) { + return (*Warns).scanValues(nil, columns) + } + _spec.Assign = func(columns []string, values []interface{}) error { + node := &Warns{config: wq.config} + nodes = append(nodes, node) + return node.assignValues(columns, values) + } + for i := range hooks { + hooks[i](ctx, _spec) + } + if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil { + return nil, err + } + if len(nodes) == 0 { + return nodes, nil + } + return nodes, nil +} + +func (wq *WarnsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := wq.querySpec() + _spec.Node.Columns = wq.fields + if len(wq.fields) > 0 { + _spec.Unique = wq.unique != nil && *wq.unique + } + return sqlgraph.CountNodes(ctx, wq.driver, _spec) +} + +func (wq *WarnsQuery) sqlExist(ctx context.Context) (bool, error) { + n, err := wq.sqlCount(ctx) + if err != nil { + return false, fmt.Errorf("ent: check existence: %w", err) + } + return n > 0, nil +} + +func (wq *WarnsQuery) querySpec() *sqlgraph.QuerySpec { + _spec := &sqlgraph.QuerySpec{ + Node: &sqlgraph.NodeSpec{ + Table: warns.Table, + Columns: warns.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: warns.FieldID, + }, + }, + From: wq.sql, + Unique: true, + } + if unique := wq.unique; unique != nil { + _spec.Unique = *unique + } + if fields := wq.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, warns.FieldID) + for i := range fields { + if fields[i] != warns.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) + } + } + } + if ps := wq.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if limit := wq.limit; limit != nil { + _spec.Limit = *limit + } + if offset := wq.offset; offset != nil { + _spec.Offset = *offset + } + if ps := wq.order; len(ps) > 0 { + _spec.Order = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + return _spec +} + +func (wq *WarnsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(wq.driver.Dialect()) + t1 := builder.Table(warns.Table) + columns := wq.fields + if len(columns) == 0 { + columns = warns.Columns + } + selector := builder.Select(t1.Columns(columns...)...).From(t1) + if wq.sql != nil { + selector = wq.sql + selector.Select(selector.Columns(columns...)...) + } + if wq.unique != nil && *wq.unique { + selector.Distinct() + } + for _, p := range wq.predicates { + p(selector) + } + for _, p := range wq.order { + p(selector) + } + if offset := wq.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 := wq.limit; limit != nil { + selector.Limit(*limit) + } + return selector +} + +// WarnsGroupBy is the group-by builder for Warns entities. +type WarnsGroupBy 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 (wgb *WarnsGroupBy) Aggregate(fns ...AggregateFunc) *WarnsGroupBy { + wgb.fns = append(wgb.fns, fns...) + return wgb +} + +// Scan applies the group-by query and scans the result into the given value. +func (wgb *WarnsGroupBy) Scan(ctx context.Context, v interface{}) error { + query, err := wgb.path(ctx) + if err != nil { + return err + } + wgb.sql = query + return wgb.sqlScan(ctx, v) +} + +func (wgb *WarnsGroupBy) sqlScan(ctx context.Context, v interface{}) error { + for _, f := range wgb.fields { + if !warns.ValidColumn(f) { + return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} + } + } + selector := wgb.sqlQuery() + if err := selector.Err(); err != nil { + return err + } + rows := &sql.Rows{} + query, args := selector.Query() + if err := wgb.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} + +func (wgb *WarnsGroupBy) sqlQuery() *sql.Selector { + selector := wgb.sql.Select() + aggregation := make([]string, 0, len(wgb.fns)) + for _, fn := range wgb.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(wgb.fields)+len(wgb.fns)) + for _, f := range wgb.fields { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + return selector.GroupBy(selector.Columns(wgb.fields...)...) +} + +// WarnsSelect is the builder for selecting fields of Warns entities. +type WarnsSelect struct { + *WarnsQuery + selector + // intermediate query (i.e. traversal path). + sql *sql.Selector +} + +// Scan applies the selector query and scans the result into the given value. +func (ws *WarnsSelect) Scan(ctx context.Context, v interface{}) error { + if err := ws.prepareQuery(ctx); err != nil { + return err + } + ws.sql = ws.WarnsQuery.sqlQuery(ctx) + return ws.sqlScan(ctx, v) +} + +func (ws *WarnsSelect) sqlScan(ctx context.Context, v interface{}) error { + rows := &sql.Rows{} + query, args := ws.sql.Query() + if err := ws.driver.Query(ctx, query, args, rows); err != nil { + return err + } + defer rows.Close() + return sql.ScanSlice(rows, v) +} diff --git a/ent/warns_update.go b/ent/warns_update.go new file mode 100644 index 0000000..6896cc2 --- /dev/null +++ b/ent/warns_update.go @@ -0,0 +1,427 @@ +// 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/warns" +) + +// WarnsUpdate is the builder for updating Warns entities. +type WarnsUpdate struct { + config + hooks []Hook + mutation *WarnsMutation +} + +// Where appends a list predicates to the WarnsUpdate builder. +func (wu *WarnsUpdate) Where(ps ...predicate.Warns) *WarnsUpdate { + wu.mutation.Where(ps...) + return wu +} + +// SetEmitter sets the "emitter" field. +func (wu *WarnsUpdate) SetEmitter(s string) *WarnsUpdate { + wu.mutation.SetEmitter(s) + return wu +} + +// SetServerid sets the "serverid" field. +func (wu *WarnsUpdate) SetServerid(s string) *WarnsUpdate { + wu.mutation.SetServerid(s) + return wu +} + +// SetTarget sets the "target" field. +func (wu *WarnsUpdate) SetTarget(s string) *WarnsUpdate { + wu.mutation.SetTarget(s) + return wu +} + +// SetType sets the "type" field. +func (wu *WarnsUpdate) SetType(s string) *WarnsUpdate { + wu.mutation.SetType(s) + return wu +} + +// SetDuration sets the "duration" field. +func (wu *WarnsUpdate) SetDuration(s string) *WarnsUpdate { + wu.mutation.SetDuration(s) + return wu +} + +// SetReason sets the "reason" field. +func (wu *WarnsUpdate) SetReason(s string) *WarnsUpdate { + wu.mutation.SetReason(s) + return wu +} + +// SetRefid sets the "refid" field. +func (wu *WarnsUpdate) SetRefid(s string) *WarnsUpdate { + wu.mutation.SetRefid(s) + return wu +} + +// Mutation returns the WarnsMutation object of the builder. +func (wu *WarnsUpdate) Mutation() *WarnsMutation { + return wu.mutation +} + +// Save executes the query and returns the number of nodes affected by the update operation. +func (wu *WarnsUpdate) Save(ctx context.Context) (int, error) { + var ( + err error + affected int + ) + if len(wu.hooks) == 0 { + affected, err = wu.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WarnsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wu.mutation = mutation + affected, err = wu.sqlSave(ctx) + mutation.done = true + return affected, err + }) + for i := len(wu.hooks) - 1; i >= 0; i-- { + if wu.hooks[i] == nil { + return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wu.hooks[i](mut) + } + if _, err := mut.Mutate(ctx, wu.mutation); err != nil { + return 0, err + } + } + return affected, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wu *WarnsUpdate) SaveX(ctx context.Context) int { + affected, err := wu.Save(ctx) + if err != nil { + panic(err) + } + return affected +} + +// Exec executes the query. +func (wu *WarnsUpdate) Exec(ctx context.Context) error { + _, err := wu.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wu *WarnsUpdate) ExecX(ctx context.Context) { + if err := wu.Exec(ctx); err != nil { + panic(err) + } +} + +func (wu *WarnsUpdate) sqlSave(ctx context.Context) (n int, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: warns.Table, + Columns: warns.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: warns.FieldID, + }, + }, + } + if ps := wu.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wu.mutation.Emitter(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldEmitter, + }) + } + if value, ok := wu.mutation.Serverid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldServerid, + }) + } + if value, ok := wu.mutation.Target(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldTarget, + }) + } + if value, ok := wu.mutation.GetType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldType, + }) + } + if value, ok := wu.mutation.Duration(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldDuration, + }) + } + if value, ok := wu.mutation.Reason(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldReason, + }) + } + if value, ok := wu.mutation.Refid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldRefid, + }) + } + if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{warns.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return 0, err + } + return n, nil +} + +// WarnsUpdateOne is the builder for updating a single Warns entity. +type WarnsUpdateOne struct { + config + fields []string + hooks []Hook + mutation *WarnsMutation +} + +// SetEmitter sets the "emitter" field. +func (wuo *WarnsUpdateOne) SetEmitter(s string) *WarnsUpdateOne { + wuo.mutation.SetEmitter(s) + return wuo +} + +// SetServerid sets the "serverid" field. +func (wuo *WarnsUpdateOne) SetServerid(s string) *WarnsUpdateOne { + wuo.mutation.SetServerid(s) + return wuo +} + +// SetTarget sets the "target" field. +func (wuo *WarnsUpdateOne) SetTarget(s string) *WarnsUpdateOne { + wuo.mutation.SetTarget(s) + return wuo +} + +// SetType sets the "type" field. +func (wuo *WarnsUpdateOne) SetType(s string) *WarnsUpdateOne { + wuo.mutation.SetType(s) + return wuo +} + +// SetDuration sets the "duration" field. +func (wuo *WarnsUpdateOne) SetDuration(s string) *WarnsUpdateOne { + wuo.mutation.SetDuration(s) + return wuo +} + +// SetReason sets the "reason" field. +func (wuo *WarnsUpdateOne) SetReason(s string) *WarnsUpdateOne { + wuo.mutation.SetReason(s) + return wuo +} + +// SetRefid sets the "refid" field. +func (wuo *WarnsUpdateOne) SetRefid(s string) *WarnsUpdateOne { + wuo.mutation.SetRefid(s) + return wuo +} + +// Mutation returns the WarnsMutation object of the builder. +func (wuo *WarnsUpdateOne) Mutation() *WarnsMutation { + return wuo.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 (wuo *WarnsUpdateOne) Select(field string, fields ...string) *WarnsUpdateOne { + wuo.fields = append([]string{field}, fields...) + return wuo +} + +// Save executes the query and returns the updated Warns entity. +func (wuo *WarnsUpdateOne) Save(ctx context.Context) (*Warns, error) { + var ( + err error + node *Warns + ) + if len(wuo.hooks) == 0 { + node, err = wuo.sqlSave(ctx) + } else { + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutation, ok := m.(*WarnsMutation) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + wuo.mutation = mutation + node, err = wuo.sqlSave(ctx) + mutation.done = true + return node, err + }) + for i := len(wuo.hooks) - 1; i >= 0; i-- { + if wuo.hooks[i] == nil { + return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = wuo.hooks[i](mut) + } + v, err := mut.Mutate(ctx, wuo.mutation) + if err != nil { + return nil, err + } + nv, ok := v.(*Warns) + if !ok { + return nil, fmt.Errorf("unexpected node type %T returned from WarnsMutation", v) + } + node = nv + } + return node, err +} + +// SaveX is like Save, but panics if an error occurs. +func (wuo *WarnsUpdateOne) SaveX(ctx context.Context) *Warns { + node, err := wuo.Save(ctx) + if err != nil { + panic(err) + } + return node +} + +// Exec executes the query on the entity. +func (wuo *WarnsUpdateOne) Exec(ctx context.Context) error { + _, err := wuo.Save(ctx) + return err +} + +// ExecX is like Exec, but panics if an error occurs. +func (wuo *WarnsUpdateOne) ExecX(ctx context.Context) { + if err := wuo.Exec(ctx); err != nil { + panic(err) + } +} + +func (wuo *WarnsUpdateOne) sqlSave(ctx context.Context) (_node *Warns, err error) { + _spec := &sqlgraph.UpdateSpec{ + Node: &sqlgraph.NodeSpec{ + Table: warns.Table, + Columns: warns.Columns, + ID: &sqlgraph.FieldSpec{ + Type: field.TypeInt, + Column: warns.FieldID, + }, + }, + } + id, ok := wuo.mutation.ID() + if !ok { + return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Warns.id" for update`)} + } + _spec.Node.ID.Value = id + if fields := wuo.fields; len(fields) > 0 { + _spec.Node.Columns = make([]string, 0, len(fields)) + _spec.Node.Columns = append(_spec.Node.Columns, warns.FieldID) + for _, f := range fields { + if !warns.ValidColumn(f) { + return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} + } + if f != warns.FieldID { + _spec.Node.Columns = append(_spec.Node.Columns, f) + } + } + } + if ps := wuo.mutation.predicates; len(ps) > 0 { + _spec.Predicate = func(selector *sql.Selector) { + for i := range ps { + ps[i](selector) + } + } + } + if value, ok := wuo.mutation.Emitter(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldEmitter, + }) + } + if value, ok := wuo.mutation.Serverid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldServerid, + }) + } + if value, ok := wuo.mutation.Target(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldTarget, + }) + } + if value, ok := wuo.mutation.GetType(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldType, + }) + } + if value, ok := wuo.mutation.Duration(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldDuration, + }) + } + if value, ok := wuo.mutation.Reason(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldReason, + }) + } + if value, ok := wuo.mutation.Refid(); ok { + _spec.Fields.Set = append(_spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeString, + Value: value, + Column: warns.FieldRefid, + }) + } + _node = &Warns{config: wuo.config} + _spec.Assign = _node.assignValues + _spec.ScanValues = _node.scanValues + if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil { + if _, ok := err.(*sqlgraph.NotFoundError); ok { + err = &NotFoundError{warns.Label} + } else if sqlgraph.IsConstraintError(err) { + err = &ConstraintError{msg: err.Error(), wrap: err} + } + return nil, err + } + return _node, nil +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..0b32f8d --- /dev/null +++ b/go.mod @@ -0,0 +1,45 @@ +module github.com/FrankenBotDev/FrankenAPI + +go 1.18 + +require ( + entgo.io/ent v0.11.1 + github.com/go-chi/chi/v5 v5.0.7 + github.com/go-chi/cors v1.2.1 + github.com/go-chi/jwtauth/v5 v5.0.2 + github.com/jackc/pgx/v4 v4.16.1 + github.com/joho/godotenv v1.4.0 +) + +require ( + ariga.io/atlas v0.5.0 // indirect + github.com/agext/levenshtein v1.2.1 // indirect + github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect + github.com/go-openapi/inflect v0.19.0 // indirect + github.com/goccy/go-json v0.7.6 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/hashicorp/hcl/v2 v2.10.0 // indirect + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.12.1 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.11.0 // indirect + github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect + github.com/lestrrat-go/blackmagic v1.0.0 // indirect + github.com/lestrrat-go/httpcc v1.0.0 // indirect + github.com/lestrrat-go/iter v1.0.1 // indirect + github.com/lestrrat-go/jwx v1.2.6 // indirect + github.com/lestrrat-go/option v1.0.0 // indirect + github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/zclconf/go-cty v1.8.0 // indirect + golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect + golang.org/x/mod v0.5.1 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e2a11e5 --- /dev/null +++ b/go.sum @@ -0,0 +1,278 @@ +ariga.io/atlas v0.5.0 h1:9HZclkGI/xsW7IqKZLIMfnUJ0Nkgm1X1nysq4SMkKsg= +ariga.io/atlas v0.5.0/go.mod h1:ofVetkJqlaWle3mvYmaS2uyFGFcc7dSq436tmxa/Mzk= +entgo.io/ent v0.11.1 h1:im67R+2W3Nee2bNS2YnoYz8oAF0Qz4AOlIvKRIAEISY= +entgo.io/ent v0.11.1/go.mod h1:X5b1YfMayrRTgKGO//8IqpL7XJx0uqdeReEkxNpXROA= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8= +github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= +github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d h1:1iy2qD6JEhHKKhUOA9IWs7mjco7lnw2qx8FsRI2wirE= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE= +github.com/go-chi/chi/v5 v5.0.4/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= +github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= +github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= +github.com/go-chi/jwtauth/v5 v5.0.2 h1:CSKtr+b6Jnfy5T27sMaiBPxaVE/bjnjS3ramFQ0526w= +github.com/go-chi/jwtauth/v5 v5.0.2/go.mod h1:TeA7vmPe3uYThvHw8O8W13HOOpOd4MTgToxL41gZyjs= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= +github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/goccy/go-json v0.7.6 h1:H0wq4jppBQ+9222sk5+hPLL25abZQiRuQ6YPnjO9c+A= +github.com/goccy/go-json v0.7.6/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/hashicorp/hcl/v2 v2.10.0 h1:1S1UnuhDGlv3gRFV4+0EdwB+znNP5HmcGbIqwnSCByg= +github.com/hashicorp/hcl/v2 v2.10.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= +github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= +github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= +github.com/jackc/pgconn v1.12.1 h1:rsDFzIpRk7xT4B8FufgpCCeyjdNpKyghZeSefViE5W8= +github.com/jackc/pgconn v1.12.1/go.mod h1:ZkhRC59Llhrq3oSfrikvwQ5NaxYExr6twkdkMLaKono= +github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= +github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= +github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= +github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.0 h1:brH0pCGBDkBW07HWlN/oSBXrmo3WB0UvZd1pIuDcL8Y= +github.com/jackc/pgproto3/v2 v2.3.0/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= +github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= +github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= +github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= +github.com/jackc/pgtype v1.11.0 h1:u4uiGPz/1hryuXzyaBhSk6dnIyyG2683olG2OV+UUgs= +github.com/jackc/pgtype v1.11.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= +github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= +github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= +github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.16.1 h1:JzTglcal01DrghUqt+PmzWsZx/Yh7SC/CTQmSBMTd0Y= +github.com/jackc/pgx/v4 v4.16.1/go.mod h1:SIhx0D5hoADaiXZVyv+3gSm3LCIIINTVO0PficsvWGQ= +github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg= +github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= +github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= +github.com/lestrrat-go/backoff/v2 v2.0.8 h1:oNb5E5isby2kiro9AgdHLv5N5tint1AnDVVf2E2un5A= +github.com/lestrrat-go/backoff/v2 v2.0.8/go.mod h1:rHP/q/r9aT27n24JQLa7JhSQZCKBBOiM/uP402WwN8Y= +github.com/lestrrat-go/blackmagic v1.0.0 h1:XzdxDbuQTz0RZZEmdU7cnQxUtFUzgCSPq8RCz4BxIi4= +github.com/lestrrat-go/blackmagic v1.0.0/go.mod h1:TNgH//0vYSs8VXDCfkZLgIrVTTXQELZffUV0tz3MtdQ= +github.com/lestrrat-go/codegen v1.0.1/go.mod h1:JhJw6OQAuPEfVKUCLItpaVLumDGWQznd1VaXrBk9TdM= +github.com/lestrrat-go/httpcc v1.0.0 h1:FszVC6cKfDvBKcJv646+lkh4GydQg2Z29scgUfkOpYc= +github.com/lestrrat-go/httpcc v1.0.0/go.mod h1:tGS/u00Vh5N6FHNkExqGGNId8e0Big+++0Gf8MBnAvE= +github.com/lestrrat-go/iter v1.0.1 h1:q8faalr2dY6o8bV45uwrxq12bRa1ezKrB6oM9FUgN4A= +github.com/lestrrat-go/iter v1.0.1/go.mod h1:zIdgO1mRKhn8l9vrZJZz9TUMMFbQbLeTsbqPDrJ/OJc= +github.com/lestrrat-go/jwx v1.2.6 h1:XAgfuHaOB7fDZ/6WhVgl8K89af768dU+3Nx4DlTbLIk= +github.com/lestrrat-go/jwx v1.2.6/go.mod h1:tJuGuAI3LC71IicTx82Mz1n3w9woAs2bYJZpkjJQ5aU= +github.com/lestrrat-go/option v1.0.0 h1:WqAWL8kh8VcSoD6xjSH34/1m8yxluXQbDeKNfvFeEO4= +github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.14.13 h1:1tj15ngiFfcZzii7yd82foL+ks+ouQcj8j/TPq3fk1I= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM= +github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942 h1:t0lM6y/M5IiUZyvbBTcngso8SZEZICH7is9B6g/obVU= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20201217014255-9d1352758620/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20210114065538-d78b04bdf963/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376 h1:sY2a+y0j4iDrajJcorb+a0hJIQ6uakU5gybjfLWHlXo= +gopkg.in/olahol/melody.v1 v1.0.0-20170518105555-d52139073376/go.mod h1:BHKOc1m5wm8WwQkMqYBoo4vNxhmF7xg8+xhG8L+Cy3M= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/main.go b/main.go new file mode 100644 index 0000000..023d57b --- /dev/null +++ b/main.go @@ -0,0 +1,201 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "log" + "net/http" + "strconv" + + "github.com/FrankenBotDev/FrankenAPI/ent/authorizables" + "github.com/FrankenBotDev/FrankenAPI/pkg/actions" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/punishments" + "github.com/FrankenBotDev/FrankenAPI/pkg/security" + "github.com/FrankenBotDev/FrankenAPI/pkg/settings" + "github.com/FrankenBotDev/FrankenAPI/pkg/stats" + "github.com/FrankenBotDev/FrankenAPI/pkg/support" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/joho/godotenv" + "gopkg.in/olahol/melody.v1" + + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" + "github.com/go-chi/cors" + "github.com/go-chi/jwtauth/v5" + _ "github.com/jackc/pgx/v4/stdlib" +) + +type LoginRequest struct { + Username string `json:username` + Password string `json:password` +} + +type GopherInfo struct { + ID, USERID, CH string +} + +type Message struct { + Command string + Payload map[string]string +} + +func main() { + mrouter := melody.New() + gophers := make(map[*melody.Session]*GopherInfo) + counter := 0 + err := godotenv.Load(".env") + if err != nil { + fmt.Println(".end could not be loaded") + log.Fatal(err) + } + client, cContext := sys.InitDB() + tokenAuth := jwtauth.New("HS256", []byte("secret"), nil) + defer client.Close() + + r := chi.NewRouter() + r.Use(middleware.Logger) + + // Basic CORS + // for more ideas, see: https://developer.github.com/v3/#cross-origin-resource-sharing + r.Use(cors.Handler(cors.Options{ + // AllowedOrigins: []string{"https://foo.com"}, // Use this to allow specific origin hosts + AllowedOrigins: []string{"https://*", "http://*"}, + // AllowOriginFunc: func(r *http.Request, origin string) bool { return true }, + AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, + AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, + ExposedHeaders: []string{"Link"}, + AllowCredentials: false, + MaxAge: 300, // Maximum value not ignored by any of major browsers + })) + + r.Use(func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := context.WithValue(r.Context(), sys.EntClientKey, client) + next.ServeHTTP(w, r.WithContext(ctx)) + }) + }) + + r.Use(func(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := context.WithValue(r.Context(), sys.ContextClientKey, cContext) + next.ServeHTTP(w, r.WithContext(ctx)) + }) + }) + + // Witout JWT + r.Group(func(r chi.Router) { + // AUTHENTIFICATION ROUTER + // using loging and password from a user to authenticate + // Returns bearer if login is succefful and error if not + r.Post("/server/auth", func(w http.ResponseWriter, r *http.Request) { + + var loginRequest LoginRequest + err := json.NewDecoder(r.Body).Decode(&loginRequest) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + // Queries requested data + user, err := client.Authorizables.Query(). + Where(authorizables.Username(loginRequest.Username), authorizables.Password(security.NewSHA256asString([]byte(loginRequest.Password)))). + All(cContext) + if err != nil { + http.Error(w, "database error", http.StatusInternalServerError) + } + + // Validates user entry if one is present login can proceed + if len(user) == 1 { + _, tokenString, err := tokenAuth.Encode(map[string]interface{}{"user_id": 1}) + if err != nil { + sys.ErrorJsonResponse(w, "encoding_error", err) + } + + raw, _ := json.Marshal(`{"type":"success", "token":"` + tokenString + `"}`) + + w.Write(raw) + return + } else { + + http.Error(w, `{"type":"error", "code":"invalid credentials"}`, http.StatusUnauthorized) + return + } + + }) + }) + + // With JWT + r.Group(func(r chi.Router) { + + r.Use(jwtauth.Verifier(tokenAuth)) + r.Use(jwtauth.Authenticator) + + r.Mount("/logger", logger.LogRouter()) + r.Mount("/server/punishments", punishments.PunRouter()) + r.Mount("/server/settings", settings.SettingsRouter()) + r.Mount("/server/actions", actions.ActionRouter()) + r.Mount("/server/support", support.SupportRouter()) + r.Mount("/stats", stats.StatsRouter()) + }) + + /* ================================================== + WEBSOCKET CODE + ================================================== */ + // Websocket Endpoint + r.Get("/ws", func(w http.ResponseWriter, r *http.Request) { + fmt.Println("websocket connection") + mrouter.HandleRequest(w, r) + }) + + // Connect Socket + mrouter.HandleConnect(func(s *melody.Session) { + fmt.Println("websocket connecting") + + // Receives data and assignes it to the gophers map + gophers[s] = &GopherInfo{strconv.Itoa(counter), s.Request.URL.Query().Get("userid"), s.Request.URL.Query().Get("channel")} + + // Message user client about Successfull Connection and tell the User + //s.Write([]byte(`{"type":"success", "id":` + gophers[s].ID + `}`)) + s.Write([]byte(`{"comamnd":"msg", "payload":{"name":"SYSTEM", "userid":"system", "type":"INFO", "msg":"You are connected to:` + s.Request.URL.Query().Get("channel") + `"} }`)) + counter += 1 + }) + + // handle message and send to correct channel after session as created for user + mrouter.HandleMessage(func(s *melody.Session, msg []byte) { + info := gophers[s] + commandJson := Message{} + json.Unmarshal(msg, &commandJson) + + // Command Handler + switch commandJson.Command { + case "msg": + raw, err := json.Marshal(`{"command":"msg", "payload":{"name":"` + commandJson.Payload["name"] + `", "userid":"` + commandJson.Payload["userid"] + `", "type":"default", "msg":"` + commandJson.Payload["msg"] + `"} }`) + if err != nil { + fmt.Println(err) + } + + mrouter.BroadcastFilter(raw, func(q *melody.Session) bool { + // log messages here + return info.CH == q.Request.URL.Query().Get("channel") + }) + } + }) + + // Deletes socket out of known Map + mrouter.HandleDisconnect(func(s *melody.Session) { + tCH := gophers[s].CH + + // Sends a message to the channel that a user left + mrouter.BroadcastFilter([]byte(gophers[s].USERID+"left the channel"), func(q *melody.Session) bool { + // log messages here + return gophers[s].CH == tCH + }) + + // Deletes a user from the internal client map + delete(gophers, s) + }) + + http.ListenAndServe(":3000", r) +} diff --git a/pkg/actions/actions.go b/pkg/actions/actions.go new file mode 100644 index 0000000..e55db54 --- /dev/null +++ b/pkg/actions/actions.go @@ -0,0 +1,263 @@ +package actions + +import ( + "context" + "encoding/json" + "errors" + "io/ioutil" + "net/http" + "strconv" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/actions" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +func ActionRouter() http.Handler { + r := chi.NewRouter() + + r.Get("/", getActions) + r.Get("/search", getActionsbyID) + r.Post("/", addAction) + r.Put("/", updateAction) + r.Delete("/", deleteAction) + + return r +} + +func getActions(w http.ResponseWriter, r *http.Request) { + actionRequest := r.URL.Query() + + if actionRequest.Get("serverid") != "" { + if actionRequest.Get("commiterid") != "" { + actions, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Actions.Query(). + Where(actions.Serverid(actionRequest.Get("serverid"))). + Order(ent.Desc(actions.FieldID)). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "could_not_fetch_from_database", err) + } + + sys.SuccessJsonResponse(w, actions) + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } +} + +func getActionsbyID(w http.ResponseWriter, r *http.Request) { + actionRequest := r.URL.Query() + + if actionRequest.Get("serverid") != "" { + if actionRequest.Get("commiterid") != "" { + if actionRequest.Get("refid") != "" { + actions, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Actions.Query(). + Where(actions.Serverid(actionRequest.Get("serverid")), actions.Refid(actionRequest.Get("refid"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "could_not_fetch_from_database", err) + } + + sys.SuccessJsonResponse(w, actions) + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("refid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } +} + +func addAction(w http.ResponseWriter, r *http.Request) { + + actionData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + actionJson := make(map[string]any) + err = json.Unmarshal(actionData, &actionJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + devRefid := sys.RandStringRunes(16) + + if actionJson["serverid"].(string) != "" { + if actionJson["comiterid"].(string) != "" { + if devRefid != "" { + if actionJson["target"].(string) != "" { + if actionJson["type"].(string) != "" { + if actionJson["duration"].(string) != "" { + if actionJson["reason"].(string) != "" { + if strconv.FormatBool(actionJson["temp"].(bool)) != "" { + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Actions.Create(). + SetRefid(devRefid). + SetServerid(actionJson["serverid"].(string)). + SetTarget(actionJson["target"].(string)). + SetType(actionJson["type"].(string)). + SetDuration(actionJson["duration"].(string)). + SetCommiter(actionJson["comiterid"].(string)). + SetReason(actionJson["reason"].(string)). + SetTemp(actionJson["temp"].(bool)). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + + logger.Logtodb([]string{ + actionJson["comiterid"].(string), + "Created action with RefID: " + devRefid, + "Action Create", + actionJson["serverid"].(string), + }, + r.Context().Value(sys.EntClientKey).(*ent.Client), + r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "data_could_not_be_updated", err) + } + + sys.SuccessJsonResponse(w, "data_updated") + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("temp needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("reason needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("duration needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("type needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("target need to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("refid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } + +} + +func deleteAction(w http.ResponseWriter, r *http.Request) { + actionData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + actionJson := make(map[string]any) + err = json.Unmarshal(actionData, &actionJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if actionJson["comiterid"].(string) != "" { + if actionJson["serverid"].(string) != "" { + if actionJson["refid"].(string) != "" { + + _, err = r.Context().Value(sys.EntClientKey).(*ent.Client).Actions.Delete(). + Where(actions.Serverid(actionJson["serverid"].(string)), actions.Refid(actionJson["refid"].(string))). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "data_could_not_be_removed", err) + } + + logger.Logtodb([]string{ + actionJson["comiterid"].(string), + "Deleted action with RefID: " + actionJson["refid"].(string), + "Action Delete", + actionJson["serverid"].(string), + }, r.Context().Value(sys.EntClientKey).(*ent.Client), + r.Context().Value(sys.ContextClientKey).(context.Context)) + + sys.SuccessJsonResponse(w, "data_updated") + + } + } + } +} + +func updateAction(w http.ResponseWriter, r *http.Request) { + actionData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + actionJson := make(map[string]any) + err = json.Unmarshal(actionData, &actionJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if actionJson["serverid"].(string) != "" { + if actionJson["commiter"].(string) != "" { + if actionJson["refid"].(string) != "" { + if actionJson["target"].(string) != "" { + if actionJson["type"].(string) != "" { + if actionJson["duration"].(string) != "" { + if actionJson["reason"].(string) != "" { + if strconv.FormatBool(actionJson["temp"].(bool)) != "" { + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Actions.Update(). + Where(actions.Serverid(actionJson["serverid"].(string)), actions.Refid(actionJson["refid"].(string))). + SetRefid(actionJson["refid"].(string)). + SetTarget(actionJson["target"].(string)). + SetType(actionJson["type"].(string)). + SetDuration(actionJson["duration"].(string)). + SetCommiter(actionJson["commiter"].(string)). + SetReason(actionJson["reason"].(string)). + SetTemp(actionJson["temp"].(bool)). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "data_could_not_be_updated", err) + } + + logger.Logtodb([]string{ + actionJson["commiter"].(string), + "Updated Action with RefID: " + actionJson["refid"].(string), + "Action Update", + actionJson["serverid"].(string), + }, r.Context().Value(sys.EntClientKey).(*ent.Client), + r.Context().Value(sys.ContextClientKey).(context.Context)) + + sys.SuccessJsonResponse(w, "data_updated") + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("temp needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("reason needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("duration needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("type needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("target need to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("refid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } +} diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go new file mode 100644 index 0000000..793fdfd --- /dev/null +++ b/pkg/logger/logger.go @@ -0,0 +1,80 @@ +package logger + +import ( + "context" + "encoding/json" + "io/ioutil" + "net/http" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/logging" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +func LogRouter() http.Handler { + r := chi.NewRouter() + + r.Get("/", getapilog) + r.Post("/", apilogger) + return r +} + +func apilogger(w http.ResponseWriter, r *http.Request) { + logJson := make(map[string]string) + logData, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, `{"type":"error", "code":"request_data_could_not_be_proccessed"}`, http.StatusInternalServerError) + return + } + + err = json.Unmarshal(logData, &logJson) + if err != nil { + http.Error(w, `{"type":"error", "code":"request_data_could_not_be_proccessed"}`, http.StatusInternalServerError) + return + } + + err = Logtodb([]string{logJson["commiterid"], logJson["description"], logJson["actiontype"], logJson["serverid"]}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + http.Error(w, `{"type":"error", "code":"could_not_create_log_in_database"}`, http.StatusInternalServerError) + return + } + + w.Write([]byte(`{"type":"success", "code":"log_added_to_database"}`)) +} + +func getapilog(w http.ResponseWriter, r *http.Request) { + loggerRequest := r.URL.Query() + + log, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Logging.Query(). + Where(logging.Serverid(loggerRequest.Get("serverid"))). + Order(ent.Desc(logging.FieldID)). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "request_data_could_not_found_or_fetched", err) + return + } + + sys.SuccessJsonResponse(w, log) +} + +// logs a given message array to the database +// message args +// 0 -> commiters id +// 1 -> description +// 2 -> action type +// 3 -> the server logged on +func Logtodb(message []string, client *ent.Client, context context.Context) error { + err := client.Logging.Create(). + SetCommiter(message[0]). + SetDescription(message[1]). + SetType(message[2]). + SetServerid(message[3]). + Exec(context) + + if err != nil { + return err + } + + return nil +} diff --git a/pkg/punishments/punishments.go b/pkg/punishments/punishments.go new file mode 100644 index 0000000..f212d53 --- /dev/null +++ b/pkg/punishments/punishments.go @@ -0,0 +1,134 @@ +package punishments + +import ( + "context" + "encoding/json" + "errors" + "net/http" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/punishments" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +func PunRouter() http.Handler { + r := chi.NewRouter() + + r.Get("/", getPun) + r.Post("/", createPun) + r.Delete("/", deletePun) + return r +} + +// WEB-SYS ONLY WHOLE ROUTE +func createPun(w http.ResponseWriter, r *http.Request) { + punData := sys.ProccessRequest(w, r.Body) + if punData == nil { + return + } + punJson := make(map[string]any) + + if punJson["commiterid"] != "" { + if punJson["serverid"].(string) != "" { + if punJson["warnamount"].(string) != "" { + if punJson["actiontype"].(string) != "" { + if punJson["duration"].(string) != "" { + if punJson["reason"].(string) != "" { + + json.Unmarshal(punData, &punJson) + err := r.Context().Value(sys.EntClientKey).(*ent.Client).Punishments.Create(). + SetServerid(punJson["serverid"].(string)). + SetWarnamount(punJson["warnamount"].(string)). + SetActiontype(punJson["actiontype"].(string)). + SetDuration(punJson["duration"].(string)). + SetReason(punJson["reason"].(string)). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "pun_could_not_be_created", err) + } + + logger.Logtodb([]string{punJson["commiterid"].(string), "type: " + punJson["actiontype"].(string) + ", duration: " + punJson["duration"].(string) + ", reason: " + punJson["reason"].(string) + ", warnamount: " + punJson["warnamount"].(string), "puncreate", punJson["serverid"].(string)}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"pun_was_created"}`)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("reason needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("duration needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("actiontype needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("warnamount needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiter needs to be set")) + } +} + +func getPun(w http.ResponseWriter, r *http.Request) { + userdata := r.URL.Query() + + if userdata.Get("commiterid") != "" { + if userdata.Get("serverid") != "" { + if userdata.Get("warnamount") != "" { + + pun, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Punishments.Query(). + Where(punishments.Serverid(userdata.Get("serverid")), punishments.Warnamount(userdata.Get("warnamount"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_pun", err) + return + } + + sys.SuccessJsonResponse(w, pun) + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("warnamount needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_paramert", errors.New("commiterid needs to be set")) + } +} + +func deletePun(w http.ResponseWriter, r *http.Request) { + punData := sys.ProccessRequest(w, r.Body) + if punData != nil { + return + } + + punJson := make(map[string]any) + + if punJson["commiterid"].(string) != "" { + if punJson["serverid"].(string) != "" { + if punJson["warnamount"].(string) != "" { + + json.Unmarshal(punData, &punJson) + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Punishments.Delete(). + Where(punishments.Serverid(punJson["serverid"].(string)), punishments.Warnamount(punJson["warnamount"].(string))). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "pun_could_not_be_created", err) + } + + logger.Logtodb([]string{punJson["commiterid"].(string), "warnamount: " + punJson["warnamount"].(string), "punremove", punJson["serverid"].(string)}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"pun_was_removed"}`)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("warnamount needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_paramert", errors.New("commiterid needs to be set")) + } +} diff --git a/pkg/security/crypto.go b/pkg/security/crypto.go new file mode 100644 index 0000000..f4ad6bc --- /dev/null +++ b/pkg/security/crypto.go @@ -0,0 +1,24 @@ +package security + +import ( + "crypto/sha256" + "encoding/hex" + "log" + "os" +) + +// NewSHA256 ... +func NewSHA256(data []byte) []byte { + if os.Getenv("SALT") == "" { + log.Fatal("CRITICAL ERROR SALT was found to be empty") + } + prep := []byte(os.Getenv("SALT") + "-") + + prep = append(prep, data...) + hash := sha256.Sum256(prep) + return hash[:] +} + +func NewSHA256asString(data []byte) string { + return hex.EncodeToString(NewSHA256(data)) +} diff --git a/pkg/security/security.go b/pkg/security/security.go new file mode 100644 index 0000000..e4bfdbc --- /dev/null +++ b/pkg/security/security.go @@ -0,0 +1,39 @@ +package security + +import ( + "net/http" + + "github.com/go-chi/chi/v5" +) + +var sysKey = "devtoken" +var dscSecret = "dscSec" +var webSecret = "webSec" + +func SecurityRouter(r chi.Router) { + r.Get("/", login) +} + +/* ============================================================== +TODO rework to make use of JWT +============================================================== */ + +// [DEPRECATED] will be replaced with jwt +// login takes in requered parameters from all incoming platforms and authorizes access if granted +func login(w http.ResponseWriter, r *http.Request) { + loginInput := r.URL.Query() + + switch loginInput.Get("platform") { + case "discord": + if loginInput.Get("s") == dscSecret { + w.Write([]byte(`{"type":"reply", "s":"` + sysKey + `"}`)) + } + case "web": + if loginInput.Get("s") == webSecret { + w.Write([]byte(`{"type":"reply", "s":"` + sysKey + `"}`)) + } + default: + http.Error(w, "invalid_platform", http.StatusInternalServerError) + return + } +} diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go new file mode 100644 index 0000000..b7ce0cd --- /dev/null +++ b/pkg/settings/settings.go @@ -0,0 +1,433 @@ +package settings + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/settings" + "github.com/FrankenBotDev/FrankenAPI/ent/socialmedia" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +func SettingsRouter() http.Handler { + r := chi.NewRouter() + + r.Get("/", getServerSettings) + r.Post("/", createServerSettings) + r.Put("/", updateServerSettings) + r.Post("/socialmedia", createSocial) + r.Put("/socialmedia", updateSocial) + r.Delete("/socialmedia", deleteSocial) + r.Get("/socialmedia", getSocial) + return r +} + +/* ========================================================== +ROUTE DEFINITIONS +=========================================================== */ +func createServerSettings(w http.ResponseWriter, r *http.Request) { + + // fetch data + settingsJson := make(map[string]any) + settingsData := sys.ProccessRequest(w, r.Body) + if settingsData == nil { + return + } + + // process data + err := json.Unmarshal(settingsData, &settingsJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if settingsJson["commiterid"] != "" { + if settingsJson["serverid"].(string) != "" { + if settingsJson["servername"].(string) != "" { + if settingsJson["ownerid"].(string) != "" { + // error handling and user communication + _, err = r.Context().Value(sys.EntClientKey).(*ent.Client).Settings.Create().SetWordfilter(false). + SetTwitterannounce(false). + SetTwitchannounce(false). + SetStatsprivate(true). + SetStatspagemode("default"). + SetStatspage(false). + SetSpamprotection(false). + SetSpamchannel("general"). + SetServername(settingsJson["servername"].(string)). + SetServerid(settingsJson["serverid"].(string)). + SetPermtoken("test"). + SetOwnerid(settingsJson["ownerid"].(string)). + SetMusic(false). + SetModeration(false). + SetLoggerchannel("general"). + SetLogger(false). + SetLinkprotection(false). + SetGreetings(false). + SetGreetermode("image"). + SetGreeterchannel("general"). + SetAutomatedmoderation(false). + SetApitoken("n/a"). + SetApitoggle(false). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "data_could_not_be_added_to_database", errors.New("inserting settings into database failed")) + } + + // Send message to the user if transaction could be made + // in this case only usefull for the bot but may be implemented to the webpage once stable implementation exists + logger.Logtodb([]string{"system", "settings for server" + settingsJson["serverid"].(string) + " was have been created", "settingscreate", settingsJson["serverid"].(string)}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"data_was_put_into_the_database"}`)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("ownerid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("servername needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "mssing_parameter", errors.New("commiterid needs to be set")) + } +} + +func updateServerSettings(w http.ResponseWriter, r *http.Request) { + // fetch data + settingsJson := make(map[string]any) + settingsData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("request body seems to be empty")) + } + + // process data + err = json.Unmarshal(settingsData, &settingsJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + fmt.Println(settingsJson) + + if commiteridStr, ok := settingsJson["commiterid"].(string); ok { + fmt.Println(0) + if serveridStr, ok := settingsJson["serverid"].(string); ok { + fmt.Println(1) + if blacklistBool, ok := settingsJson["blacklist"].(bool); ok { + fmt.Println(2) + if twitchannounceBool, ok := settingsJson["twitchannounce"].(bool); ok { + fmt.Println(3) + if twitterannounceBool, ok := settingsJson["twitteranounce"].(bool); ok { + fmt.Println(4) + if statsprivateBool, ok := settingsJson["statsprivate"].(bool); ok { + fmt.Println(5) + if statspagemodeStr, ok := settingsJson["statspagemode"].(string); ok { + fmt.Println(6) + if statspageBool, ok := settingsJson["statspage"].(bool); ok { + fmt.Println(7) + if spamprotectBool, ok := settingsJson["spamprotect"].(bool); ok { + fmt.Println(8) + if spamchannelStr, ok := settingsJson["spamchannel"].(string); ok { + fmt.Println(9) + if servernameStr, ok := settingsJson["servername"].(string); ok { + fmt.Println(10) + if musicBool, ok := settingsJson["music"].(bool); ok { + fmt.Println(11) + if moderationBool, ok := settingsJson["moderation"].(bool); ok { + fmt.Println(12) + if loggerchannelStr, ok := settingsJson["loggerchannel"].(string); ok { + fmt.Println(13) + if loggerBool, ok := settingsJson["logger"].(bool); ok { + fmt.Println(14) + if linkprotectBool, ok := settingsJson["linkprotect"].(bool); ok { + fmt.Println(15) + if helloBool, ok := settingsJson["greetings"].(bool); ok { + fmt.Println(16) + if greetingstypeStr, ok := settingsJson["greetingtype"].(string); ok { + fmt.Println(17) + if greetingschannelStr, ok := settingsJson["greetingchannel"].(string); ok { + fmt.Println(18) + if automodBool, ok := settingsJson["automod"].(bool); ok { + fmt.Println(19) + if apiBool, ok := settingsJson["apitoggle"].(bool); ok { + fmt.Println(20) + if statsBool, ok := settingsJson["stats"].(bool); ok { + fmt.Println(21) + if anounceChannelStr, ok := settingsJson["announcechannel"].(string); ok { + fmt.Println(21) + + fmt.Println(spamprotectBool) + fmt.Println(linkprotectBool) + fmt.Println(blacklistBool) + fmt.Println(apiBool) + + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Settings.Update(). + Where(settings.Serverid(serveridStr)). + SetWordfilter(blacklistBool). + SetTwitterannounce(twitterannounceBool). + SetTwitchannounce(twitchannounceBool). + SetStatsprivate(statsprivateBool). + SetStatspagemode(statspagemodeStr). + SetStatspage(statspageBool). + SetSpamprotection(spamprotectBool). + SetSpamchannel(spamchannelStr). + SetServername(servernameStr). + SetMusic(musicBool). + SetModeration(moderationBool). + SetLoggerchannel(loggerchannelStr). + SetLogger(loggerBool). + SetLinkprotection(linkprotectBool). + SetGreetings(helloBool). + SetGreetermode(greetingstypeStr). + SetGreeterchannel(greetingschannelStr). + SetAutomatedmoderation(automodBool). + SetApitoggle(apiBool). + SetStats(statsBool). + SetAnnouncechannel(anounceChannelStr). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + fmt.Println(err) + http.Error(w, `{"type":"error", "code":"could_update_database"}`, http.StatusInternalServerError) + return + } + + logger.Logtodb([]string{commiteridStr, "settings for server: " + serveridStr + " was changed by: " + commiteridStr, "settingschange", serveridStr}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"data_was_updated_in_the_database"}`)) + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("announcechannel needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("stats needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("apitoggle needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("automod needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("greetingchannel needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("greetingtype needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("greetings needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("linkprotect needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("logger needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("loggerchannel needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("moderation needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("music needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("servername needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("spamchannel needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("spamprotect needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("statspage needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("statspagemode needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("statsprivate needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("twitchannounce needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("twitteranounce needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("blacklist needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +func getServerSettings(w http.ResponseWriter, r *http.Request) { + settingsQuery := r.URL.Query() + + if settingsQuery.Get("commiterid") != "" { + if settingsQuery.Get("serverid") != "" { + // replace with actual api data + user, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Settings.Query().Where(settings.Serverid(settingsQuery.Get("serverid"))).All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("the requested user was not found")) + } + + sys.SuccessJsonResponse(w, user) + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +func createSocial(w http.ResponseWriter, r *http.Request) { + // fetch data + settingsJson := make(map[string]any) + settingsData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("could not find data in that request")) + } + + // process data + err = json.Unmarshal(settingsData, &settingsJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + if settingsJson["commiterid"].(string) != "" { + if settingsJson["serverid"].(string) != "" { + if settingsJson["identifier"].(string) != "" { + if settingsJson["type"].(string) != "" { + + r.Context().Value(sys.EntClientKey).(*ent.Client).Socialmedia.Create(). + SetServerid(settingsJson["serverid"].(string)). + SetIdentificator(settingsJson["identifier"].(string)). + SetType(settingsJson["type"].(string)). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + + logger.Logtodb([]string{settingsJson["commiterid"].(string), "socialmedia entry for server" + settingsJson["serverid"].(string) + " was added by" + settingsJson["commiterid"].(string), "socialcreate", settingsJson["serverid"].(string)}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"data_was_put_into_the_database"}`)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("type needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("identifier needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +/* ======================================================== +todo: update all below todo comments asap +======================================================== */ + +// @TODO: actually updating the database +func updateSocial(w http.ResponseWriter, r *http.Request) { + // fetch data + settingsJson := make(map[string]any) + settingsData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("could not find data in that request")) + } + + // process data + err = json.Unmarshal(settingsData, &settingsJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if settingsJson["commiterid"].(string) != "" { + if settingsJson["serverid"].(string) != "" { + if settingsJson["identifier"].(string) != "" { + if settingsJson["type"].(string) != "" { + + _, err = r.Context().Value(sys.EntClientKey).(*ent.Client).Socialmedia.Update(). + SetServerid(settingsJson["serverid"].(string)). + SetIdentificator(settingsJson["identifier"].(string)). + SetType(settingsJson["type"].(string)). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "database_error", errors.New("could not update the database")) + } + + logger.Logtodb([]string{settingsJson["commiterid"].(string), "socialmedia entry for server" + settingsJson["serverid"].(string) + " was updated by" + settingsJson["commiterid"].(string), "socialupdate", settingsJson["serverid"].(string)}, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + w.Write([]byte(`{"type":"success", "code":"data_was_put_into_the_database"}`)) + + } + } + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +// @TODO fetch parameters from request query +func deleteSocial(w http.ResponseWriter, r *http.Request) { + + if r.URL.Query().Get("commiterid") != "" { + if r.URL.Query().Get("serverid") != "" { + if r.URL.Query().Get("identifier") != "" { + + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Socialmedia.Delete(). + Where(socialmedia.Serverid(r.URL.Query().Get("serverid")), socialmedia.Identificator(r.URL.Query().Get("identifier"))). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "data_could_not_be_deleted", errors.New("the data requested could not be removed")) + } + + w.Write([]byte(`{"type":"success", "code":"data_was_removed_successfully"}`)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("identifier needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +// @TODO user userdata to manipulate the db query +func getSocial(w http.ResponseWriter, r *http.Request) { + userData := r.URL.Query() + fmt.Println(userData) + + if userData.Get("commiterid") != "" { + if userData.Get("serverid") != "" { + if userData.Get("identifer") != "" { + + // replace with actual api data + social, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Socialmedia.Query(). + Where(socialmedia.Serverid(userData.Get("serverid")), socialmedia.Identificator(userData.Get("identifer"))).All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("could not get the requested user object")) + } + sys.SuccessJsonResponse(w, social) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("identifier needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} diff --git a/pkg/stats/stats.go b/pkg/stats/stats.go new file mode 100644 index 0000000..ab7e01e --- /dev/null +++ b/pkg/stats/stats.go @@ -0,0 +1,194 @@ +package stats + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "time" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/user" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +// TODO: error handle route properly +func StatsRouter() http.Handler { + r := chi.NewRouter() + + r.Post("/user", createUser) + r.Get("/user", getUser) + r.Get("/server", getServer) + r.Put("/user", updateUser) + + return r +} + +/* ========================================================== +ROUTE DEFINITIONS +=========================================================== */ +func createUser(w http.ResponseWriter, r *http.Request) { + // fetch data + userJson := make(map[string]any) + userData, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, `"type":"error", "code":"could_not_find_data_in_request"`, http.StatusInternalServerError) + return + } + + // process data + err = json.Unmarshal(userData, &userJson) + if err != nil { + http.Error(w, `{"type":"error", "code":"could_not_proccess_data"}`, http.StatusInternalServerError) + return + } + + if userJson["commiterid"].(string) != "" { + if userJson["serverid"].(string) != "" { + if userJson["userid"].(string) != "" { + if userJson["username"].(string) != "" { + + // push data to database + _, err = r.Context().Value(sys.EntClientKey).(*ent.Client).User.Create(). + SetServerid(userJson["serverid"].(string)). + SetUserid(userJson["userid"].(string)). + SetLevel(1). + SetUsername(userJson["username"].(string)). + SetXp(0). + SetMsgs(0). + SetCreated(time.Now()). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_add_data_to_database", errors.New("data could not be added to the database")) + } + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("username needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("userid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +func updateUser(w http.ResponseWriter, r *http.Request) { + // daten fetchen + userData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + userJson := make(map[string]any) + err = json.Unmarshal(userData, &userJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if userJson["committerid"].(string) != "" { + if userJson["serverid"].(string) != "" { + if userJson["userid"].(string) != "" { + if levelNum, ok := userJson["level"].(float64); ok { + if xpNum, ok := userJson["xp"].(float64); ok { + if msgsNum, ok := userJson["msgs"].(float64); ok { + + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).User.Update(). + Where(user.Serverid(userJson["serverid"].(string)), user.Userid(userJson["userid"].(string))). + SetLevel(int(levelNum)). + SetXp(int(xpNum)). + SetMsgs(int(msgsNum)). + Save(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + fmt.Println(err) + } + + logger.Logtodb([]string{ + userJson["committerid"].(string), + "Updated User with UserID: " + userJson["userid"].(string), + "User Update", + userJson["serverid"].(string), + }, r.Context().Value(sys.EntClientKey).(*ent.Client), + r.Context().Value(sys.ContextClientKey).(context.Context)) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("msgs needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("xp needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("level needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("userid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +func getUser(w http.ResponseWriter, r *http.Request) { + userData := r.URL.Query() + fmt.Println(userData) + + if userData.Get("commiterid") != "" { + if userData.Get("serverid") != "" { + if userData.Get("userid") != "" { + + // replace with actual api data + user, err := r.Context().Value(sys.EntClientKey).(*ent.Client).User.Query(). + Where(user.Serverid(userData.Get("serverid")), user.Userid(userData.Get("userid"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + sys.SuccessJsonResponse(w, user) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("userid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} + +func getServer(w http.ResponseWriter, r *http.Request) { + serverData := r.URL.Query() + + if serverData.Get("commiterid") != "" { + if serverData.Get("serverid") != "" { + + // replace with actual api data + user, err := r.Context().Value(sys.EntClientKey).(*ent.Client).User.Query(). + Where(user.Serverid(serverData.Get("serverid"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + sys.SuccessJsonResponse(w, user) + + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("serverid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_parameter", errors.New("commiterid needs to be set")) + } +} diff --git a/pkg/support/support.go b/pkg/support/support.go new file mode 100644 index 0000000..cc57e3e --- /dev/null +++ b/pkg/support/support.go @@ -0,0 +1,332 @@ +package support + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "time" + + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/support" + "github.com/FrankenBotDev/FrankenAPI/ent/supportresponse" + "github.com/FrankenBotDev/FrankenAPI/pkg/logger" + "github.com/FrankenBotDev/FrankenAPI/pkg/sys" + "github.com/go-chi/chi/v5" +) + +// TODO: error handle route properly +func SupportRouter() http.Handler { + r := chi.NewRouter() + + r.Get("/", getTicket) + r.Get("/search", getTicketByID) + r.Post("/", openTicket) + r.Put("/", updateTicket) + r.Delete("/", deleteTicket) + r.Post("/message", writetMessage) + r.Get("/message", getMessages) + r.Get("/message/unread", getUnreadMessages) + return r +} + +func getTicket(w http.ResponseWriter, r *http.Request) { + ticketQuery := r.URL.Query() + + if ticketQuery.Get("serverid") != "" { + ticket, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Support.Query(). + Where(support.Serverid(ticketQuery.Get("serverid")), support.Not(support.Status("closed"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + sys.SuccessJsonResponse(w, ticket) + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } +} + +func getTicketByID(w http.ResponseWriter, r *http.Request) { + ticketQuery := r.URL.Query() + + if ticketQuery.Get("serverid") != "" { + if ticketQuery.Get("refid") != "" { + + // replace with actual api data + ticket, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Support.Query(). + Where(support.Serverid(ticketQuery.Get("serverid")), support.Refid(ticketQuery.Get("refid"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + sys.SuccessJsonResponse(w, ticket) + + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("refid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("serverid needs to be set")) + } +} + +func openTicket(w http.ResponseWriter, r *http.Request) { + // daten fetchen + ticketData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + ticketJson := make(map[string]any) + err = json.Unmarshal(ticketData, &ticketJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + devRefid := sys.RandStringRunes(16) + + if serveridStr, ok := ticketJson["serverid"].(string); ok { + if devRefid != "" { + if titleStr, ok := ticketJson["title"].(string); ok { + if descStr, ok := ticketJson["description"].(string); ok { + if creatorStr, ok := ticketJson["creator"].(string); ok { + // replace with actual api data + err := r.Context().Value(sys.EntClientKey).(*ent.Client).Support.Create(). + SetServerid(serveridStr). + SetRefid(devRefid). + SetStatus("open"). + SetTitle(titleStr). + SetDescription(descStr). + SetCreator(creatorStr). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + logger.Logtodb([]string{ + creatorStr, + "Opened Support Ticket with RefiD: " + devRefid, + "Support Ticket Open", + serveridStr, + }, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + + sys.SuccessJsonResponse(w, "ticket_created") + } + } + } + } + } +} + +func updateTicket(w http.ResponseWriter, r *http.Request) { + // daten fetchen + ticketData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + ticketJson := make(map[string]any) + err = json.Unmarshal(ticketData, &ticketJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + fmt.Println(ticketJson) + + if commiteridStr, ok := ticketJson["commiterid"].(string); ok { + fmt.Println(0) + if serveridStr, ok := ticketJson["serverid"].(string); ok { + fmt.Println(1) + if refidStr, ok := ticketJson["refid"].(string); ok { + fmt.Println(2) + if statusStr, ok := ticketJson["status"].(string); ok { + fmt.Println(3) + if titleStr, ok := ticketJson["title"].(string); ok { + fmt.Println(4) + if descStr, ok := ticketJson["description"].(string); ok { + fmt.Println(5) + if creatorStr, ok := ticketJson["creator"].(string); ok { + fmt.Println(6) + // replace with actual api data + err := r.Context().Value(sys.EntClientKey).(*ent.Client).Support.Update(). + Where(support.Refid(refidStr), support.Serverid(serveridStr)). + SetServerid(serveridStr). + SetRefid(refidStr). + SetStatus(statusStr). + SetTitle(titleStr). + SetDescription(descStr). + SetCreator(creatorStr). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + logger.Logtodb([]string{ + commiteridStr, + "Updated Support Ticket with RefiD: " + refidStr, + "Support Ticket Update", + serveridStr, + }, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + sys.SuccessJsonResponse(w, "ticket_created") + } + } + } + } + } + } + } +} + +func deleteTicket(w http.ResponseWriter, r *http.Request) { + // daten fetchen + ticketData, err := ioutil.ReadAll(r.Body) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_find_data_in_request", errors.New("the request appears to be empty")) + } + + // proccess data + ticketJson := make(map[string]any) + err = json.Unmarshal(ticketData, &ticketJson) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_proccess_data", errors.New("request data could not be proccessed")) + } + + if commiteridStr, ok := ticketJson["commiterid"].(string); ok { + if serveridStr, ok := ticketJson["serverid"].(string); ok { + if refidStr, ok := ticketJson["refid"].(string); ok { + // replace with actual api data + _, err := r.Context().Value(sys.EntClientKey).(*ent.Client).Support.Delete(). + Where(support.Serverid(serveridStr), support.Refid(refidStr)). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + if err != nil { + sys.ErrorJsonResponse(w, "could_not_get_user", errors.New("requested user could not be fetched from the database")) + } + + logger.Logtodb([]string{ + commiteridStr, + "Removed Support Ticket with RefiD: " + refidStr, + "Support Ticket Remove", + serveridStr, + }, r.Context().Value(sys.EntClientKey).(*ent.Client), r.Context().Value(sys.ContextClientKey).(context.Context)) + sys.SuccessJsonResponse(w, "ticket_created") + + sys.SuccessJsonResponse(w, "ticket_created") + } + } + } +} + +func getMessages(w http.ResponseWriter, r *http.Request) { + tickerResponseQuery := r.URL.Query() + + if tickerResponseQuery.Get("refid") != "" { + if tickerResponseQuery.Get("commiterid") != "" { + replies, err := r.Context().Value(sys.EntClientKey).(*ent.Client).SupportResponse.Query(). + Where(supportresponse.Refid(tickerResponseQuery.Get("refid"))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "database_error", errors.New("could not get responses from database")) + } + + sys.SuccessJsonResponse(w, replies) + } else { + sys.ErrorJsonResponse(w, "missing_params", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_params", errors.New("refid needs to be set")) + } +} + +func getUnreadMessages(w http.ResponseWriter, r *http.Request) { + tickerResponseQuery := r.URL.Query() + + if tickerResponseQuery.Get("refid") != "" { + if tickerResponseQuery.Get("commiterid") != "" { + replies, err := r.Context().Value(sys.EntClientKey).(*ent.Client).SupportResponse.Query(). + Where(supportresponse.Refid(tickerResponseQuery.Get("refid")), supportresponse.Not(supportresponse.Isread(false))). + All(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + sys.ErrorJsonResponse(w, "database_error", errors.New("could not get responses from database")) + } + + sys.SuccessJsonResponse(w, replies) + } else { + sys.ErrorJsonResponse(w, "missing_params", errors.New("commiterid needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_params", errors.New("refid needs to be set")) + } +} + +func writetMessage(w http.ResponseWriter, r *http.Request) { + // fetch data + ticketResponseJson := make(map[string]any) + ticketResponseData, err := ioutil.ReadAll(r.Body) + if err != nil { + http.Error(w, `"type":"error", "code":"could_not_find_data_in_request"`, http.StatusInternalServerError) + return + } + + // process data + err = json.Unmarshal(ticketResponseData, &ticketResponseJson) + if err != nil { + http.Error(w, `{"type":"error", "code":"could_not_proccess_data"}`, http.StatusInternalServerError) + return + } + if refidStr, ok := ticketResponseJson["refid"].(string); ok { + fmt.Println(0) + if messageStr, ok := ticketResponseJson["message"].(string); ok { + fmt.Println(1) + if rtcChannelStr, ok := ticketResponseJson["rtcchannel"].(string); ok { + fmt.Println(2) + if writerStr, ok := ticketResponseJson["writer"].(string); ok { + fmt.Println(3) + if isReadBool, ok := ticketResponseJson["isread"].(bool); ok { + fmt.Println(4) + if typeStr, ok := ticketResponseJson["type"].(string); ok { + fmt.Println(5) + err := r.Context().Value(sys.EntClientKey).(*ent.Client).SupportResponse.Create(). + SetRefid(refidStr). + SetMessage(messageStr). + SetRtcchannel(rtcChannelStr). + SetWriter(writerStr). + SetIsread(isReadBool). + SetType(typeStr). + SetCreated(time.Now()). + Exec(r.Context().Value(sys.ContextClientKey).(context.Context)) + + if err != nil { + fmt.Println(err) + sys.ErrorJsonResponse(w, "database_error", errors.New("could not post to database")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("type needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("isread needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("writer need sto e set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("rtcchannel needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("message needs to be set")) + } + } else { + sys.ErrorJsonResponse(w, "missing_param", errors.New("refid needs to be set")) + } +} + +/* ===================================================== +Websocket Code +===================================================== */ +// TODO: move code to this route diff --git a/pkg/sys/data.go b/pkg/sys/data.go new file mode 100644 index 0000000..f377222 --- /dev/null +++ b/pkg/sys/data.go @@ -0,0 +1,29 @@ +package sys + +import ( + "io" + "io/ioutil" + "math/rand" + "net/http" + "time" +) + +func ProccessRequest(w http.ResponseWriter, body io.ReadCloser) []byte { + data, err := ioutil.ReadAll(body) + if err != nil { + ErrorJsonResponse(w, "could_not_proccess_request_data", err) + } + + return data +} + +var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") + +func RandStringRunes(n int) string { + rand.Seed(time.Now().UnixNano()) + b := make([]rune, n) + for i := range b { + b[i] = letterRunes[rand.Intn(len(letterRunes))] + } + return string(b) +} diff --git a/pkg/sys/database.go b/pkg/sys/database.go new file mode 100644 index 0000000..eb1de3c --- /dev/null +++ b/pkg/sys/database.go @@ -0,0 +1,55 @@ +package sys + +import ( + "context" + "database/sql" + "log" + "os" + + entsql "entgo.io/ent/dialect/sql" + + "entgo.io/ent/dialect" + "github.com/FrankenBotDev/FrankenAPI/ent" + "github.com/FrankenBotDev/FrankenAPI/ent/migrate" +) + +type ContextKey string + +const ( + EntClientKey = ContextKey("ent_client") +) + +const ( + ContextClientKey = ContextKey("ent_context") +) + +// InitDB handles postgres client creation +func InitDB() (*ent.Client, context.Context) { + client := open(os.Getenv("DATABASE")) // TODO move this to config + ctx := context.Background() + if err := client.Schema.Create(ctx); err != nil { + log.Fatal(err) + } + + // Run migration. + err := client.Schema.Create( + ctx, + migrate.WithDropIndex(true), + migrate.WithDropColumn(true), + ) + if err != nil { + log.Fatalf("failed creating schema resources: %v", err) + } + return client, ctx +} + +// open establishes a postgres connection and returns a client +func open(databaseUrl string) *ent.Client { + db, err := sql.Open("pgx", databaseUrl) + if err != nil { + log.Fatal(err) + } + + drv := entsql.OpenDB(dialect.Postgres, db) + return ent.NewClient(ent.Driver(drv)) +} diff --git a/pkg/sys/permission.go b/pkg/sys/permission.go new file mode 100644 index 0000000..a4b0102 --- /dev/null +++ b/pkg/sys/permission.go @@ -0,0 +1,40 @@ +package sys + +import ( + "errors" + "reflect" +) + +var sysKey = "devtoken" + +// [DEPRECATED] (This has to be redone the token system wont work as intended) might be reused on a differnt point (api access maybe) +// ValidatePermToken validates a given token against the settings object of a given server +/* func ValidatePermToken(permtoken string, serverid string) (error, bool) { + token, err := sys.Client.Settings.Query().Where(settings.Serverid(serverid)).Select(settings.FieldPermtoken).All(sys.Ctx) + + if err != nil { + return errors.New("could_not_fetch_token_from_database"), false + } + + if token[0].Permtoken == permtoken { + return nil, true + } + + return nil, false +} */ + +// [deprecated] will be replaced with jwt entierly +// ValidateAuthToken validates a given token against the settings object of a given server +// Used to prevent third parties of using unallowed routes +func ValidateAuthToken(toValidate string) (error, bool) { + if reflect.TypeOf(toValidate).String() != "string" { + return errors.New("token given is not of type string"), false + } + + // Validate token agains system known token + if toValidate == sysKey { + return nil, true + } else { + return nil, false + } +} diff --git a/pkg/sys/requests.go b/pkg/sys/requests.go new file mode 100644 index 0000000..9b8c531 --- /dev/null +++ b/pkg/sys/requests.go @@ -0,0 +1,36 @@ +package sys + +import ( + "encoding/json" + "net/http" +) + +func SuccessJsonResponse(w http.ResponseWriter, data interface{}) { + raw, err := json.Marshal(data) + if err != nil { + // @TODO generic error + http.Error(w, `{"type":"error", "code":"request_data_could_prepared_for_reply"}`, http.StatusInternalServerError) + return + } + + w.Write(raw) +} + +func ErrorJsonResponse(w http.ResponseWriter, code string, err error) { + raw, err := json.Marshal(struct { + Type string + Code string + Msg string + }{ + Type: "error", + Code: code, + Msg: err.Error(), + }) + if err != nil { + // @TODO generic error + http.Error(w, `{"type":"error", "code":"request_data_could_prepared_for_reply"}`, http.StatusInternalServerError) + return + } + + w.Write(raw) +} diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/web/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/web/README.md b/web/README.md new file mode 100644 index 0000000..30b15e2 --- /dev/null +++ b/web/README.md @@ -0,0 +1,16 @@ +# Vue 3 + TypeScript + Vite + +This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` + + diff --git a/web/package-lock.json b/web/package-lock.json new file mode 100644 index 0000000..574eb0c --- /dev/null +++ b/web/package-lock.json @@ -0,0 +1,2776 @@ +{ + "name": "my-vue-app", + "version": "0.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "my-vue-app", + "version": "0.0.0", + "dependencies": { + "chart.js": "^3.9.1", + "daisyui": "^2.24.0", + "vue": "^3.2.37", + "vue-chartjs": "^4.1.1", + "vue-router": "^4.1.3" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^3.0.3", + "autoprefixer": "^10.4.8", + "postcss": "^8.4.16", + "tailwindcss": "^3.1.8", + "typescript": "^4.6.4", + "vite": "^3.0.7", + "vue-tsc": "^0.39.5" + } + }, + "node_modules/@babel/parser": { + "version": "7.18.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.11.tgz", + "integrity": "sha512-9JKn5vN+hDt0Hdqn1PiJ2guflwP+B6Ga8qbDuoF0PzzVhrzsKIJo8yGqVk6CmMHiMei9w1C1Bp9IMJSIK+HPIQ==", + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz", + "integrity": "sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@vitejs/plugin-vue": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-3.0.3.tgz", + "integrity": "sha512-U4zNBlz9mg+TA+i+5QPc3N5lQvdUXENZLO2h0Wdzp56gI1MWhqJOv+6R+d4kOzoaSSq6TnGPBdZAXKOe4lXy6g==", + "dev": true, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^3.0.0", + "vue": "^3.2.25" + } + }, + "node_modules/@volar/code-gen": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/code-gen/-/code-gen-0.39.5.tgz", + "integrity": "sha512-vQr5VoCH8T2NHmqLc/AA1/4F8l41WB+24+I+VjxBaev/Hmwjye9K0GlmMHAOl84WB3hWGOqpHaPX6JkqzRNjJg==", + "dev": true, + "dependencies": { + "@volar/source-map": "0.39.5" + } + }, + "node_modules/@volar/source-map": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-0.39.5.tgz", + "integrity": "sha512-IVOX+v++Sr5Kok4/cLbDJp2vf1ia1rChpV7adgcnMle6uORBuGFEur234UzamK0iHRCcfFFRz7z+hSPf2CO23Q==", + "dev": true + }, + "node_modules/@volar/typescript-faster": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/typescript-faster/-/typescript-faster-0.39.5.tgz", + "integrity": "sha512-IzLqlxefmKkjNKXC/8aFiqPcTqnj6RG31D2f9cIWxmW9pvUYJxLED+y9phnOxNxq0OmeRtQ3Pfmvu85tUBoZsQ==", + "dev": true, + "dependencies": { + "semver": "^7.3.7" + } + }, + "node_modules/@volar/vue-code-gen": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-code-gen/-/vue-code-gen-0.39.5.tgz", + "integrity": "sha512-y+QUV9MuuasiIuRoGKQl+gMhDaAX6XNhckAyJCvD1FZ8f2eJuPY2VtoFxmu/Z2bGWBdtUW/g98jaeKJ+j3wwOw==", + "dev": true, + "dependencies": { + "@volar/code-gen": "0.39.5", + "@volar/source-map": "0.39.5", + "@vue/compiler-core": "^3.2.37", + "@vue/compiler-dom": "^3.2.37", + "@vue/shared": "^3.2.37" + } + }, + "node_modules/@volar/vue-language-core": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-language-core/-/vue-language-core-0.39.5.tgz", + "integrity": "sha512-m+e1tYuL/WRPhSeC7hZ0NuSwHsfnnGJVxCBHLaP7jR0f6xcC0DAegP3QF+gfu9ZJFPGznpZYFKadngMjuhQS9Q==", + "dev": true, + "dependencies": { + "@volar/code-gen": "0.39.5", + "@volar/source-map": "0.39.5", + "@volar/vue-code-gen": "0.39.5", + "@vue/compiler-sfc": "^3.2.37", + "@vue/reactivity": "^3.2.37" + } + }, + "node_modules/@volar/vue-typescript": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-typescript/-/vue-typescript-0.39.5.tgz", + "integrity": "sha512-ckhWD1xOi0OMr702XVkv/Npsb9FKAp5gvhxyLv0QqWekPdSo04t4KrZfwosJLGERIEcyr50SuB7HqBp8ndQmzA==", + "dev": true, + "dependencies": { + "@volar/code-gen": "0.39.5", + "@volar/typescript-faster": "0.39.5", + "@volar/vue-language-core": "0.39.5" + } + }, + "node_modules/@vue/compiler-core": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.37.tgz", + "integrity": "sha512-81KhEjo7YAOh0vQJoSmAD68wLfYqJvoiD4ulyedzF+OEk/bk6/hx3fTNVfuzugIIaTrOx4PGx6pAiBRe5e9Zmg==", + "dependencies": { + "@babel/parser": "^7.16.4", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "source-map": "^0.6.1" + } + }, + "node_modules/@vue/compiler-dom": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.37.tgz", + "integrity": "sha512-yxJLH167fucHKxaqXpYk7x8z7mMEnXOw3G2q62FTkmsvNxu4FQSu5+3UMb+L7fjKa26DEzhrmCxAgFLLIzVfqQ==", + "dependencies": { + "@vue/compiler-core": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "node_modules/@vue/compiler-sfc": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.37.tgz", + "integrity": "sha512-+7i/2+9LYlpqDv+KTtWhOZH+pa8/HnX/905MdVmAcI/mPQOBwkHHIzrsEsucyOIZQYMkXUiTkmZq5am/NyXKkg==", + "dependencies": { + "@babel/parser": "^7.16.4", + "@vue/compiler-core": "3.2.37", + "@vue/compiler-dom": "3.2.37", + "@vue/compiler-ssr": "3.2.37", + "@vue/reactivity-transform": "3.2.37", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "magic-string": "^0.25.7", + "postcss": "^8.1.10", + "source-map": "^0.6.1" + } + }, + "node_modules/@vue/compiler-ssr": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.37.tgz", + "integrity": "sha512-7mQJD7HdXxQjktmsWp/J67lThEIcxLemz1Vb5I6rYJHR5vI+lON3nPGOH3ubmbvYGt8xEUaAr1j7/tIFWiEOqw==", + "dependencies": { + "@vue/compiler-dom": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "node_modules/@vue/devtools-api": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.2.1.tgz", + "integrity": "sha512-OEgAMeQXvCoJ+1x8WyQuVZzFo0wcyCmUR3baRVLmKBo1LmYZWMlRiXlux5jd0fqVJu6PfDbOrZItVqUEzLobeQ==" + }, + "node_modules/@vue/reactivity": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.37.tgz", + "integrity": "sha512-/7WRafBOshOc6m3F7plwzPeCu/RCVv9uMpOwa/5PiY1Zz+WLVRWiy0MYKwmg19KBdGtFWsmZ4cD+LOdVPcs52A==", + "dependencies": { + "@vue/shared": "3.2.37" + } + }, + "node_modules/@vue/reactivity-transform": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.37.tgz", + "integrity": "sha512-IWopkKEb+8qpu/1eMKVeXrK0NLw9HicGviJzhJDEyfxTR9e1WtpnnbYkJWurX6WwoFP0sz10xQg8yL8lgskAZg==", + "dependencies": { + "@babel/parser": "^7.16.4", + "@vue/compiler-core": "3.2.37", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "magic-string": "^0.25.7" + } + }, + "node_modules/@vue/runtime-core": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.37.tgz", + "integrity": "sha512-JPcd9kFyEdXLl/i0ClS7lwgcs0QpUAWj+SKX2ZC3ANKi1U4DOtiEr6cRqFXsPwY5u1L9fAjkinIdB8Rz3FoYNQ==", + "dependencies": { + "@vue/reactivity": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "node_modules/@vue/runtime-dom": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.37.tgz", + "integrity": "sha512-HimKdh9BepShW6YozwRKAYjYQWg9mQn63RGEiSswMbW+ssIht1MILYlVGkAGGQbkhSh31PCdoUcfiu4apXJoPw==", + "dependencies": { + "@vue/runtime-core": "3.2.37", + "@vue/shared": "3.2.37", + "csstype": "^2.6.8" + } + }, + "node_modules/@vue/server-renderer": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.37.tgz", + "integrity": "sha512-kLITEJvaYgZQ2h47hIzPh2K3jG8c1zCVbp/o/bzQOyvzaKiCquKS7AaioPI28GNxIsE/zSx+EwWYsNxDCX95MA==", + "dependencies": { + "@vue/compiler-ssr": "3.2.37", + "@vue/shared": "3.2.37" + }, + "peerDependencies": { + "vue": "3.2.37" + } + }, + "node_modules/@vue/shared": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.37.tgz", + "integrity": "sha512-4rSJemR2NQIo9Klm1vabqWjD8rs/ZaJSzMxkMNeJS6lHiUjjUeYFbooN19NgFjztubEKh3WlZUeOLVdbbUWHsw==" + }, + "node_modules/acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-node": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", + "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", + "dependencies": { + "acorn": "^7.0.0", + "acorn-walk": "^7.0.0", + "xtend": "^4.0.2" + } + }, + "node_modules/acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" + }, + "node_modules/autoprefixer": { + "version": "10.4.8", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.8.tgz", + "integrity": "sha512-75Jr6Q/XpTqEf6D2ltS5uMewJIx5irCU1oBYJrWjFenq/m12WRRrz6g15L1EIoYvPLXTbEry7rDOwrcYNj77xw==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/autoprefixer" + } + ], + "dependencies": { + "browserslist": "^4.21.3", + "caniuse-lite": "^1.0.30001373", + "fraction.js": "^4.2.0", + "normalize-range": "^0.1.2", + "picocolors": "^1.0.0", + "postcss-value-parser": "^4.2.0" + }, + "bin": { + "autoprefixer": "bin/autoprefixer" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "peerDependencies": { + "postcss": "^8.1.0" + } + }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "engines": { + "node": ">=8" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.21.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", + "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001370", + "electron-to-chromium": "^1.4.202", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.5" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==", + "engines": { + "node": ">= 6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001378", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001378.tgz", + "integrity": "sha512-JVQnfoO7FK7WvU4ZkBRbPjaot4+YqxogSDosHv0Hv5mWpUESmN+UubMU6L/hGz8QlQ2aY5U0vR6MOs6j/CXpNA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] + }, + "node_modules/chart.js": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.9.1.tgz", + "integrity": "sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==" + }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "dependencies": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + }, + "engines": { + "node": ">=12.5.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "node_modules/css-selector-tokenizer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz", + "integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==", + "dependencies": { + "cssesc": "^3.0.0", + "fastparse": "^1.1.2" + } + }, + "node_modules/cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==", + "bin": { + "cssesc": "bin/cssesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/csstype": { + "version": "2.6.20", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.20.tgz", + "integrity": "sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==" + }, + "node_modules/daisyui": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-2.24.0.tgz", + "integrity": "sha512-Fdu/4LCdTfWLWAbCuPxvnaRotEfJ+hVPgZ2kv/aUk9RZ00Yk8fGdJtIf0kXJ3IgUKOr8rCXUpfQY6DQU9usPCQ==", + "dependencies": { + "color": "^4.2", + "css-selector-tokenizer": "^0.8.0", + "postcss-js": "^4.0.0", + "tailwindcss": "^3" + }, + "peerDependencies": { + "autoprefixer": "^10.0.2", + "postcss": "^8.1.6" + } + }, + "node_modules/defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha512-Y2caI5+ZwS5c3RiNDJ6u53VhQHv+hHKwhkI1iHvceKUHw9Df6EK2zRLfjejRgMuCuxK7PfSWIMwWecceVvThjQ==" + }, + "node_modules/detective": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", + "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", + "dependencies": { + "acorn-node": "^1.8.2", + "defined": "^1.0.0", + "minimist": "^1.2.6" + }, + "bin": { + "detective": "bin/detective.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" + }, + "node_modules/dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" + }, + "node_modules/electron-to-chromium": { + "version": "1.4.224", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.224.tgz", + "integrity": "sha512-dOujC5Yzj0nOVE23iD5HKqrRSDj2SD7RazpZS/b/WX85MtO6/LzKDF4TlYZTBteB+7fvSg5JpWh0sN7fImNF8w==" + }, + "node_modules/esbuild": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz", + "integrity": "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/linux-loong64": "0.14.54", + "esbuild-android-64": "0.14.54", + "esbuild-android-arm64": "0.14.54", + "esbuild-darwin-64": "0.14.54", + "esbuild-darwin-arm64": "0.14.54", + "esbuild-freebsd-64": "0.14.54", + "esbuild-freebsd-arm64": "0.14.54", + "esbuild-linux-32": "0.14.54", + "esbuild-linux-64": "0.14.54", + "esbuild-linux-arm": "0.14.54", + "esbuild-linux-arm64": "0.14.54", + "esbuild-linux-mips64le": "0.14.54", + "esbuild-linux-ppc64le": "0.14.54", + "esbuild-linux-riscv64": "0.14.54", + "esbuild-linux-s390x": "0.14.54", + "esbuild-netbsd-64": "0.14.54", + "esbuild-openbsd-64": "0.14.54", + "esbuild-sunos-64": "0.14.54", + "esbuild-windows-32": "0.14.54", + "esbuild-windows-64": "0.14.54", + "esbuild-windows-arm64": "0.14.54" + } + }, + "node_modules/esbuild-android-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz", + "integrity": "sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-android-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz", + "integrity": "sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz", + "integrity": "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-darwin-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz", + "integrity": "sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz", + "integrity": "sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-freebsd-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz", + "integrity": "sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-32": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz", + "integrity": "sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz", + "integrity": "sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz", + "integrity": "sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz", + "integrity": "sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-mips64le": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz", + "integrity": "sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-ppc64le": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz", + "integrity": "sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-riscv64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz", + "integrity": "sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-linux-s390x": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz", + "integrity": "sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-netbsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz", + "integrity": "sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-openbsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz", + "integrity": "sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-sunos-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz", + "integrity": "sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-32": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz", + "integrity": "sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz", + "integrity": "sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/esbuild-windows-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz", + "integrity": "sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "node_modules/fast-glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", + "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/fastparse": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", + "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==" + }, + "node_modules/fastq": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fraction.js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", + "integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==", + "engines": { + "node": "*" + }, + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/infusion" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-core-module": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/lilconfig": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.6.tgz", + "integrity": "sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==", + "engines": { + "node": ">=10" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "dependencies": { + "sourcemap-codec": "^1.4.8" + } + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==", + "engines": { + "node": ">= 6" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postcss": { + "version": "8.4.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", + "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + } + ], + "dependencies": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "dependencies": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + }, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "postcss": "^8.0.0" + } + }, + "node_modules/postcss-js": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.0.tgz", + "integrity": "sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==", + "dependencies": { + "camelcase-css": "^2.0.1" + }, + "engines": { + "node": "^12 || ^14 || >= 16" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": "^8.3.3" + } + }, + "node_modules/postcss-load-config": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", + "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==", + "dependencies": { + "lilconfig": "^2.0.5", + "yaml": "^1.10.2" + }, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/postcss-nested": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-5.0.6.tgz", + "integrity": "sha512-rKqm2Fk0KbA8Vt3AdGN0FB9OBOMDVajMG6ZCf/GoHgdxUJ4sBFp0A/uMIRm+MJUdo33YXEtjqIz8u7DAp8B7DA==", + "dependencies": { + "postcss-selector-parser": "^6.0.6" + }, + "engines": { + "node": ">=12.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": "^8.2.14" + } + }, + "node_modules/postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "dependencies": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/read-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", + "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "dependencies": { + "pify": "^2.3.0" + } + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "dependencies": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "2.77.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.77.3.tgz", + "integrity": "sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==" + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tailwindcss": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz", + "integrity": "sha512-YSneUCZSFDYMwk+TGq8qYFdCA3yfBRdBlS7txSq0LUmzyeqRe3a8fBQzbz9M3WS/iFT4BNf/nmw9mEzrnSaC0g==", + "dependencies": { + "arg": "^5.0.2", + "chokidar": "^3.5.3", + "color-name": "^1.1.4", + "detective": "^5.2.1", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "lilconfig": "^2.0.6", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.0.0", + "postcss": "^8.4.14", + "postcss-import": "^14.1.0", + "postcss-js": "^4.0.0", + "postcss-load-config": "^3.1.4", + "postcss-nested": "5.0.6", + "postcss-selector-parser": "^6.0.10", + "postcss-value-parser": "^4.2.0", + "quick-lru": "^5.1.1", + "resolve": "^1.22.1" + }, + "bin": { + "tailwind": "lib/cli.js", + "tailwindcss": "lib/cli.js" + }, + "engines": { + "node": ">=12.13.0" + }, + "peerDependencies": { + "postcss": "^8.0.9" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", + "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "browserslist-lint": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/vite": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.8.tgz", + "integrity": "sha512-AOZ4eN7mrkJiOLuw8IA7piS4IdOQyQCA81GxGsAQvAZzMRi9ZwGB3TOaYsj4uLAWK46T5L4AfQ6InNGlxX30IQ==", + "dev": true, + "dependencies": { + "esbuild": "^0.14.47", + "postcss": "^8.4.16", + "resolve": "^1.22.1", + "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "less": "*", + "sass": "*", + "stylus": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "stylus": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vue": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.37.tgz", + "integrity": "sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ==", + "dependencies": { + "@vue/compiler-dom": "3.2.37", + "@vue/compiler-sfc": "3.2.37", + "@vue/runtime-dom": "3.2.37", + "@vue/server-renderer": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "node_modules/vue-chartjs": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/vue-chartjs/-/vue-chartjs-4.1.1.tgz", + "integrity": "sha512-rKIQ3jPrjhwxjKdNJppnYxRuBSrx4QeM3nNHsfIxEqjX6QS4Jq6e6vnZBxh2MDpURDC2uvuI2N0eIt1cWXbBVA==", + "peerDependencies": { + "chart.js": "^3.7.0", + "vue": "^3.0.0-0 || ^2.6.0" + } + }, + "node_modules/vue-router": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.3.tgz", + "integrity": "sha512-XvK81bcYglKiayT7/vYAg/f36ExPC4t90R/HIpzrZ5x+17BOWptXLCrEPufGgZeuq68ww4ekSIMBZY1qdUdfjA==", + "dependencies": { + "@vue/devtools-api": "^6.1.4" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "vue": "^3.2.0" + } + }, + "node_modules/vue-tsc": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.39.5.tgz", + "integrity": "sha512-jhTsrKhZkafpIeN4Cbhr1K53hNfa/oesSrlh7hUaeHyCk55VhZT6oJkwJbtqN4MYkWZIwPrm3/xTwsELuf2ocg==", + "dev": true, + "dependencies": { + "@volar/vue-language-core": "0.39.5", + "@volar/vue-typescript": "0.39.5" + }, + "bin": { + "vue-tsc": "bin/vue-tsc.js" + }, + "peerDependencies": { + "typescript": "*" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "engines": { + "node": ">=0.4" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", + "engines": { + "node": ">= 6" + } + } + }, + "dependencies": { + "@babel/parser": { + "version": "7.18.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.18.11.tgz", + "integrity": "sha512-9JKn5vN+hDt0Hdqn1PiJ2guflwP+B6Ga8qbDuoF0PzzVhrzsKIJo8yGqVk6CmMHiMei9w1C1Bp9IMJSIK+HPIQ==" + }, + "@esbuild/linux-loong64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz", + "integrity": "sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==", + "dev": true, + "optional": true + }, + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==" + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, + "@vitejs/plugin-vue": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-vue/-/plugin-vue-3.0.3.tgz", + "integrity": "sha512-U4zNBlz9mg+TA+i+5QPc3N5lQvdUXENZLO2h0Wdzp56gI1MWhqJOv+6R+d4kOzoaSSq6TnGPBdZAXKOe4lXy6g==", + "dev": true, + "requires": {} + }, + "@volar/code-gen": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/code-gen/-/code-gen-0.39.5.tgz", + "integrity": "sha512-vQr5VoCH8T2NHmqLc/AA1/4F8l41WB+24+I+VjxBaev/Hmwjye9K0GlmMHAOl84WB3hWGOqpHaPX6JkqzRNjJg==", + "dev": true, + "requires": { + "@volar/source-map": "0.39.5" + } + }, + "@volar/source-map": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-0.39.5.tgz", + "integrity": "sha512-IVOX+v++Sr5Kok4/cLbDJp2vf1ia1rChpV7adgcnMle6uORBuGFEur234UzamK0iHRCcfFFRz7z+hSPf2CO23Q==", + "dev": true + }, + "@volar/typescript-faster": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/typescript-faster/-/typescript-faster-0.39.5.tgz", + "integrity": "sha512-IzLqlxefmKkjNKXC/8aFiqPcTqnj6RG31D2f9cIWxmW9pvUYJxLED+y9phnOxNxq0OmeRtQ3Pfmvu85tUBoZsQ==", + "dev": true, + "requires": { + "semver": "^7.3.7" + } + }, + "@volar/vue-code-gen": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-code-gen/-/vue-code-gen-0.39.5.tgz", + "integrity": "sha512-y+QUV9MuuasiIuRoGKQl+gMhDaAX6XNhckAyJCvD1FZ8f2eJuPY2VtoFxmu/Z2bGWBdtUW/g98jaeKJ+j3wwOw==", + "dev": true, + "requires": { + "@volar/code-gen": "0.39.5", + "@volar/source-map": "0.39.5", + "@vue/compiler-core": "^3.2.37", + "@vue/compiler-dom": "^3.2.37", + "@vue/shared": "^3.2.37" + } + }, + "@volar/vue-language-core": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-language-core/-/vue-language-core-0.39.5.tgz", + "integrity": "sha512-m+e1tYuL/WRPhSeC7hZ0NuSwHsfnnGJVxCBHLaP7jR0f6xcC0DAegP3QF+gfu9ZJFPGznpZYFKadngMjuhQS9Q==", + "dev": true, + "requires": { + "@volar/code-gen": "0.39.5", + "@volar/source-map": "0.39.5", + "@volar/vue-code-gen": "0.39.5", + "@vue/compiler-sfc": "^3.2.37", + "@vue/reactivity": "^3.2.37" + } + }, + "@volar/vue-typescript": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/@volar/vue-typescript/-/vue-typescript-0.39.5.tgz", + "integrity": "sha512-ckhWD1xOi0OMr702XVkv/Npsb9FKAp5gvhxyLv0QqWekPdSo04t4KrZfwosJLGERIEcyr50SuB7HqBp8ndQmzA==", + "dev": true, + "requires": { + "@volar/code-gen": "0.39.5", + "@volar/typescript-faster": "0.39.5", + "@volar/vue-language-core": "0.39.5" + } + }, + "@vue/compiler-core": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.2.37.tgz", + "integrity": "sha512-81KhEjo7YAOh0vQJoSmAD68wLfYqJvoiD4ulyedzF+OEk/bk6/hx3fTNVfuzugIIaTrOx4PGx6pAiBRe5e9Zmg==", + "requires": { + "@babel/parser": "^7.16.4", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "source-map": "^0.6.1" + } + }, + "@vue/compiler-dom": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.2.37.tgz", + "integrity": "sha512-yxJLH167fucHKxaqXpYk7x8z7mMEnXOw3G2q62FTkmsvNxu4FQSu5+3UMb+L7fjKa26DEzhrmCxAgFLLIzVfqQ==", + "requires": { + "@vue/compiler-core": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "@vue/compiler-sfc": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.2.37.tgz", + "integrity": "sha512-+7i/2+9LYlpqDv+KTtWhOZH+pa8/HnX/905MdVmAcI/mPQOBwkHHIzrsEsucyOIZQYMkXUiTkmZq5am/NyXKkg==", + "requires": { + "@babel/parser": "^7.16.4", + "@vue/compiler-core": "3.2.37", + "@vue/compiler-dom": "3.2.37", + "@vue/compiler-ssr": "3.2.37", + "@vue/reactivity-transform": "3.2.37", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "magic-string": "^0.25.7", + "postcss": "^8.1.10", + "source-map": "^0.6.1" + } + }, + "@vue/compiler-ssr": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.2.37.tgz", + "integrity": "sha512-7mQJD7HdXxQjktmsWp/J67lThEIcxLemz1Vb5I6rYJHR5vI+lON3nPGOH3ubmbvYGt8xEUaAr1j7/tIFWiEOqw==", + "requires": { + "@vue/compiler-dom": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "@vue/devtools-api": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.2.1.tgz", + "integrity": "sha512-OEgAMeQXvCoJ+1x8WyQuVZzFo0wcyCmUR3baRVLmKBo1LmYZWMlRiXlux5jd0fqVJu6PfDbOrZItVqUEzLobeQ==" + }, + "@vue/reactivity": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.2.37.tgz", + "integrity": "sha512-/7WRafBOshOc6m3F7plwzPeCu/RCVv9uMpOwa/5PiY1Zz+WLVRWiy0MYKwmg19KBdGtFWsmZ4cD+LOdVPcs52A==", + "requires": { + "@vue/shared": "3.2.37" + } + }, + "@vue/reactivity-transform": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.2.37.tgz", + "integrity": "sha512-IWopkKEb+8qpu/1eMKVeXrK0NLw9HicGviJzhJDEyfxTR9e1WtpnnbYkJWurX6WwoFP0sz10xQg8yL8lgskAZg==", + "requires": { + "@babel/parser": "^7.16.4", + "@vue/compiler-core": "3.2.37", + "@vue/shared": "3.2.37", + "estree-walker": "^2.0.2", + "magic-string": "^0.25.7" + } + }, + "@vue/runtime-core": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.2.37.tgz", + "integrity": "sha512-JPcd9kFyEdXLl/i0ClS7lwgcs0QpUAWj+SKX2ZC3ANKi1U4DOtiEr6cRqFXsPwY5u1L9fAjkinIdB8Rz3FoYNQ==", + "requires": { + "@vue/reactivity": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "@vue/runtime-dom": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.2.37.tgz", + "integrity": "sha512-HimKdh9BepShW6YozwRKAYjYQWg9mQn63RGEiSswMbW+ssIht1MILYlVGkAGGQbkhSh31PCdoUcfiu4apXJoPw==", + "requires": { + "@vue/runtime-core": "3.2.37", + "@vue/shared": "3.2.37", + "csstype": "^2.6.8" + } + }, + "@vue/server-renderer": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.2.37.tgz", + "integrity": "sha512-kLITEJvaYgZQ2h47hIzPh2K3jG8c1zCVbp/o/bzQOyvzaKiCquKS7AaioPI28GNxIsE/zSx+EwWYsNxDCX95MA==", + "requires": { + "@vue/compiler-ssr": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "@vue/shared": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.2.37.tgz", + "integrity": "sha512-4rSJemR2NQIo9Klm1vabqWjD8rs/ZaJSzMxkMNeJS6lHiUjjUeYFbooN19NgFjztubEKh3WlZUeOLVdbbUWHsw==" + }, + "acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==" + }, + "acorn-node": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", + "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", + "requires": { + "acorn": "^7.0.0", + "acorn-walk": "^7.0.0", + "xtend": "^4.0.2" + } + }, + "acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==" + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" + }, + "autoprefixer": { + "version": "10.4.8", + "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.8.tgz", + "integrity": "sha512-75Jr6Q/XpTqEf6D2ltS5uMewJIx5irCU1oBYJrWjFenq/m12WRRrz6g15L1EIoYvPLXTbEry7rDOwrcYNj77xw==", + "requires": { + "browserslist": "^4.21.3", + "caniuse-lite": "^1.0.30001373", + "fraction.js": "^4.2.0", + "normalize-range": "^0.1.2", + "picocolors": "^1.0.0", + "postcss-value-parser": "^4.2.0" + } + }, + "binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==" + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "browserslist": { + "version": "4.21.3", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.3.tgz", + "integrity": "sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==", + "requires": { + "caniuse-lite": "^1.0.30001370", + "electron-to-chromium": "^1.4.202", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.5" + } + }, + "camelcase-css": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", + "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==" + }, + "caniuse-lite": { + "version": "1.0.30001378", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001378.tgz", + "integrity": "sha512-JVQnfoO7FK7WvU4ZkBRbPjaot4+YqxogSDosHv0Hv5mWpUESmN+UubMU6L/hGz8QlQ2aY5U0vR6MOs6j/CXpNA==" + }, + "chart.js": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/chart.js/-/chart.js-3.9.1.tgz", + "integrity": "sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w==" + }, + "chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "requires": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "fsevents": "~2.3.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, + "color": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/color/-/color-4.2.3.tgz", + "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==", + "requires": { + "color-convert": "^2.0.1", + "color-string": "^1.9.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "requires": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "css-selector-tokenizer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz", + "integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==", + "requires": { + "cssesc": "^3.0.0", + "fastparse": "^1.1.2" + } + }, + "cssesc": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", + "integrity": "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==" + }, + "csstype": { + "version": "2.6.20", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.20.tgz", + "integrity": "sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==" + }, + "daisyui": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-2.24.0.tgz", + "integrity": "sha512-Fdu/4LCdTfWLWAbCuPxvnaRotEfJ+hVPgZ2kv/aUk9RZ00Yk8fGdJtIf0kXJ3IgUKOr8rCXUpfQY6DQU9usPCQ==", + "requires": { + "color": "^4.2", + "css-selector-tokenizer": "^0.8.0", + "postcss-js": "^4.0.0", + "tailwindcss": "^3" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha512-Y2caI5+ZwS5c3RiNDJ6u53VhQHv+hHKwhkI1iHvceKUHw9Df6EK2zRLfjejRgMuCuxK7PfSWIMwWecceVvThjQ==" + }, + "detective": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", + "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", + "requires": { + "acorn-node": "^1.8.2", + "defined": "^1.0.0", + "minimist": "^1.2.6" + } + }, + "didyoumean": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", + "integrity": "sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==" + }, + "dlv": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/dlv/-/dlv-1.1.3.tgz", + "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==" + }, + "electron-to-chromium": { + "version": "1.4.224", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.224.tgz", + "integrity": "sha512-dOujC5Yzj0nOVE23iD5HKqrRSDj2SD7RazpZS/b/WX85MtO6/LzKDF4TlYZTBteB+7fvSg5JpWh0sN7fImNF8w==" + }, + "esbuild": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.54.tgz", + "integrity": "sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==", + "dev": true, + "requires": { + "@esbuild/linux-loong64": "0.14.54", + "esbuild-android-64": "0.14.54", + "esbuild-android-arm64": "0.14.54", + "esbuild-darwin-64": "0.14.54", + "esbuild-darwin-arm64": "0.14.54", + "esbuild-freebsd-64": "0.14.54", + "esbuild-freebsd-arm64": "0.14.54", + "esbuild-linux-32": "0.14.54", + "esbuild-linux-64": "0.14.54", + "esbuild-linux-arm": "0.14.54", + "esbuild-linux-arm64": "0.14.54", + "esbuild-linux-mips64le": "0.14.54", + "esbuild-linux-ppc64le": "0.14.54", + "esbuild-linux-riscv64": "0.14.54", + "esbuild-linux-s390x": "0.14.54", + "esbuild-netbsd-64": "0.14.54", + "esbuild-openbsd-64": "0.14.54", + "esbuild-sunos-64": "0.14.54", + "esbuild-windows-32": "0.14.54", + "esbuild-windows-64": "0.14.54", + "esbuild-windows-arm64": "0.14.54" + } + }, + "esbuild-android-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz", + "integrity": "sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==", + "dev": true, + "optional": true + }, + "esbuild-android-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz", + "integrity": "sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==", + "dev": true, + "optional": true + }, + "esbuild-darwin-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz", + "integrity": "sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==", + "dev": true, + "optional": true + }, + "esbuild-darwin-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz", + "integrity": "sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz", + "integrity": "sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==", + "dev": true, + "optional": true + }, + "esbuild-freebsd-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz", + "integrity": "sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==", + "dev": true, + "optional": true + }, + "esbuild-linux-32": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz", + "integrity": "sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==", + "dev": true, + "optional": true + }, + "esbuild-linux-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz", + "integrity": "sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz", + "integrity": "sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==", + "dev": true, + "optional": true + }, + "esbuild-linux-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz", + "integrity": "sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==", + "dev": true, + "optional": true + }, + "esbuild-linux-mips64le": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz", + "integrity": "sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==", + "dev": true, + "optional": true + }, + "esbuild-linux-ppc64le": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz", + "integrity": "sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==", + "dev": true, + "optional": true + }, + "esbuild-linux-riscv64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz", + "integrity": "sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==", + "dev": true, + "optional": true + }, + "esbuild-linux-s390x": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz", + "integrity": "sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==", + "dev": true, + "optional": true + }, + "esbuild-netbsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz", + "integrity": "sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==", + "dev": true, + "optional": true + }, + "esbuild-openbsd-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz", + "integrity": "sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==", + "dev": true, + "optional": true + }, + "esbuild-sunos-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz", + "integrity": "sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==", + "dev": true, + "optional": true + }, + "esbuild-windows-32": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz", + "integrity": "sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==", + "dev": true, + "optional": true + }, + "esbuild-windows-64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz", + "integrity": "sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==", + "dev": true, + "optional": true + }, + "esbuild-windows-arm64": { + "version": "0.14.54", + "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz", + "integrity": "sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==", + "dev": true, + "optional": true + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==" + }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" + }, + "fast-glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.11.tgz", + "integrity": "sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==", + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "dependencies": { + "glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "requires": { + "is-glob": "^4.0.1" + } + } + } + }, + "fastparse": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", + "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==" + }, + "fastq": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.13.0.tgz", + "integrity": "sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==", + "requires": { + "reusify": "^1.0.4" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fraction.js": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", + "integrity": "sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==" + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "requires": { + "is-glob": "^4.0.3" + } + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "requires": { + "binary-extensions": "^2.0.0" + } + }, + "is-core-module": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + }, + "lilconfig": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.0.6.tgz", + "integrity": "sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "magic-string": { + "version": "0.25.9", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz", + "integrity": "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==", + "requires": { + "sourcemap-codec": "^1.4.8" + } + }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "minimist": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + }, + "node-releases": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==" + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "normalize-range": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/normalize-range/-/normalize-range-0.1.2.tgz", + "integrity": "sha512-bdok/XvKII3nUpklnV6P2hxtMNrCboOjAcyBuQnWEhO665FwrSNRxU+AqpsyvO6LgGYPspN+lu5CLtw4jPRKNA==" + }, + "object-hash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz", + "integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==" + }, + "postcss": { + "version": "8.4.16", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz", + "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==", + "requires": { + "nanoid": "^3.3.4", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.2" + } + }, + "postcss-import": { + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/postcss-import/-/postcss-import-14.1.0.tgz", + "integrity": "sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==", + "requires": { + "postcss-value-parser": "^4.0.0", + "read-cache": "^1.0.0", + "resolve": "^1.1.7" + } + }, + "postcss-js": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/postcss-js/-/postcss-js-4.0.0.tgz", + "integrity": "sha512-77QESFBwgX4irogGVPgQ5s07vLvFqWr228qZY+w6lW599cRlK/HmnlivnnVUxkjHnCu4J16PDMHcH+e+2HbvTQ==", + "requires": { + "camelcase-css": "^2.0.1" + } + }, + "postcss-load-config": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", + "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==", + "requires": { + "lilconfig": "^2.0.5", + "yaml": "^1.10.2" + } + }, + "postcss-nested": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/postcss-nested/-/postcss-nested-5.0.6.tgz", + "integrity": "sha512-rKqm2Fk0KbA8Vt3AdGN0FB9OBOMDVajMG6ZCf/GoHgdxUJ4sBFp0A/uMIRm+MJUdo33YXEtjqIz8u7DAp8B7DA==", + "requires": { + "postcss-selector-parser": "^6.0.6" + } + }, + "postcss-selector-parser": { + "version": "6.0.10", + "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz", + "integrity": "sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==", + "requires": { + "cssesc": "^3.0.0", + "util-deprecate": "^1.0.2" + } + }, + "postcss-value-parser": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", + "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" + }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==" + }, + "quick-lru": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz", + "integrity": "sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==" + }, + "read-cache": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", + "integrity": "sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==", + "requires": { + "pify": "^2.3.0" + } + }, + "readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "requires": { + "picomatch": "^2.2.1" + } + }, + "resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "requires": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==" + }, + "rollup": { + "version": "2.77.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.77.3.tgz", + "integrity": "sha512-/qxNTG7FbmefJWoeeYJFbHehJ2HNWnjkAFRKzWN/45eNBBF/r8lo992CwcJXEzyVxs5FmfId+vTSTQDb+bxA+g==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "requires": { + "queue-microtask": "^1.2.2" + } + }, + "semver": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "requires": { + "is-arrayish": "^0.3.1" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==" + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "tailwindcss": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz", + "integrity": "sha512-YSneUCZSFDYMwk+TGq8qYFdCA3yfBRdBlS7txSq0LUmzyeqRe3a8fBQzbz9M3WS/iFT4BNf/nmw9mEzrnSaC0g==", + "requires": { + "arg": "^5.0.2", + "chokidar": "^3.5.3", + "color-name": "^1.1.4", + "detective": "^5.2.1", + "didyoumean": "^1.2.2", + "dlv": "^1.1.3", + "fast-glob": "^3.2.11", + "glob-parent": "^6.0.2", + "is-glob": "^4.0.3", + "lilconfig": "^2.0.6", + "normalize-path": "^3.0.0", + "object-hash": "^3.0.0", + "picocolors": "^1.0.0", + "postcss": "^8.4.14", + "postcss-import": "^14.1.0", + "postcss-js": "^4.0.0", + "postcss-load-config": "^3.1.4", + "postcss-nested": "5.0.6", + "postcss-selector-parser": "^6.0.10", + "postcss-value-parser": "^4.2.0", + "quick-lru": "^5.1.1", + "resolve": "^1.22.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + } + }, + "typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true + }, + "update-browserslist-db": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz", + "integrity": "sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q==", + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "vite": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-3.0.8.tgz", + "integrity": "sha512-AOZ4eN7mrkJiOLuw8IA7piS4IdOQyQCA81GxGsAQvAZzMRi9ZwGB3TOaYsj4uLAWK46T5L4AfQ6InNGlxX30IQ==", + "dev": true, + "requires": { + "esbuild": "^0.14.47", + "fsevents": "~2.3.2", + "postcss": "^8.4.16", + "resolve": "^1.22.1", + "rollup": ">=2.75.6 <2.77.0 || ~2.77.0" + } + }, + "vue": { + "version": "3.2.37", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.2.37.tgz", + "integrity": "sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ==", + "requires": { + "@vue/compiler-dom": "3.2.37", + "@vue/compiler-sfc": "3.2.37", + "@vue/runtime-dom": "3.2.37", + "@vue/server-renderer": "3.2.37", + "@vue/shared": "3.2.37" + } + }, + "vue-chartjs": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/vue-chartjs/-/vue-chartjs-4.1.1.tgz", + "integrity": "sha512-rKIQ3jPrjhwxjKdNJppnYxRuBSrx4QeM3nNHsfIxEqjX6QS4Jq6e6vnZBxh2MDpURDC2uvuI2N0eIt1cWXbBVA==", + "requires": {} + }, + "vue-router": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.1.3.tgz", + "integrity": "sha512-XvK81bcYglKiayT7/vYAg/f36ExPC4t90R/HIpzrZ5x+17BOWptXLCrEPufGgZeuq68ww4ekSIMBZY1qdUdfjA==", + "requires": { + "@vue/devtools-api": "^6.1.4" + } + }, + "vue-tsc": { + "version": "0.39.5", + "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.39.5.tgz", + "integrity": "sha512-jhTsrKhZkafpIeN4Cbhr1K53hNfa/oesSrlh7hUaeHyCk55VhZT6oJkwJbtqN4MYkWZIwPrm3/xTwsELuf2ocg==", + "dev": true, + "requires": { + "@volar/vue-language-core": "0.39.5", + "@volar/vue-typescript": "0.39.5" + } + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "yaml": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", + "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==" + } + } +} diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..3435499 --- /dev/null +++ b/web/package.json @@ -0,0 +1,27 @@ +{ + "name": "my-vue-app", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vue-tsc --noEmit && vite build", + "preview": "vite preview" + }, + "dependencies": { + "chart.js": "^3.9.1", + "daisyui": "^2.24.0", + "vue": "^3.2.37", + "vue-chartjs": "^4.1.1", + "vue-router": "^4.1.3" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^3.0.3", + "autoprefixer": "^10.4.8", + "postcss": "^8.4.16", + "tailwindcss": "^3.1.8", + "typescript": "^4.6.4", + "vite": "^3.0.7", + "vue-tsc": "^0.39.5" + } +} diff --git a/web/postcss.config.cjs b/web/postcss.config.cjs new file mode 100644 index 0000000..33ad091 --- /dev/null +++ b/web/postcss.config.cjs @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/web/public/frankenbot.png b/web/public/frankenbot.png new file mode 100644 index 0000000..e9341ec Binary files /dev/null and b/web/public/frankenbot.png differ diff --git a/web/public/vite.svg b/web/public/vite.svg new file mode 100644 index 0000000..e7b8dfb --- /dev/null +++ b/web/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/App.vue b/web/src/App.vue new file mode 100644 index 0000000..284e9c2 --- /dev/null +++ b/web/src/App.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/web/src/assets/frankenbot.png b/web/src/assets/frankenbot.png new file mode 100644 index 0000000..e9341ec Binary files /dev/null and b/web/src/assets/frankenbot.png differ diff --git a/web/src/assets/vue.svg b/web/src/assets/vue.svg new file mode 100644 index 0000000..770e9d3 --- /dev/null +++ b/web/src/assets/vue.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/src/components/Dashboard.vue b/web/src/components/Dashboard.vue new file mode 100644 index 0000000..2830463 --- /dev/null +++ b/web/src/components/Dashboard.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/web/src/components/Home.vue b/web/src/components/Home.vue new file mode 100644 index 0000000..c2fb843 --- /dev/null +++ b/web/src/components/Home.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/web/src/components/Login.vue b/web/src/components/Login.vue new file mode 100644 index 0000000..de295b1 --- /dev/null +++ b/web/src/components/Login.vue @@ -0,0 +1,72 @@ + + + + + diff --git a/web/src/components/dashboard/Logs.vue b/web/src/components/dashboard/Logs.vue new file mode 100644 index 0000000..31ddced --- /dev/null +++ b/web/src/components/dashboard/Logs.vue @@ -0,0 +1,74 @@ + + + + + diff --git a/web/src/components/dashboard/actions.vue b/web/src/components/dashboard/actions.vue new file mode 100644 index 0000000..5516028 --- /dev/null +++ b/web/src/components/dashboard/actions.vue @@ -0,0 +1,217 @@ + + + + + diff --git a/web/src/components/dashboard/parts/actions.vue b/web/src/components/dashboard/parts/actions.vue new file mode 100644 index 0000000..2315a1e --- /dev/null +++ b/web/src/components/dashboard/parts/actions.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/web/src/components/dashboard/parts/log.vue b/web/src/components/dashboard/parts/log.vue new file mode 100644 index 0000000..54dab6d --- /dev/null +++ b/web/src/components/dashboard/parts/log.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/web/src/components/dashboard/parts/messenger_message.vue b/web/src/components/dashboard/parts/messenger_message.vue new file mode 100644 index 0000000..d94972d --- /dev/null +++ b/web/src/components/dashboard/parts/messenger_message.vue @@ -0,0 +1,26 @@ + + + + + diff --git a/web/src/components/dashboard/parts/support_ticket.vue b/web/src/components/dashboard/parts/support_ticket.vue new file mode 100644 index 0000000..aa1e50e --- /dev/null +++ b/web/src/components/dashboard/parts/support_ticket.vue @@ -0,0 +1,25 @@ + + + + + diff --git a/web/src/components/dashboard/parts/user.vue b/web/src/components/dashboard/parts/user.vue new file mode 100644 index 0000000..6dcb9f7 --- /dev/null +++ b/web/src/components/dashboard/parts/user.vue @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/web/src/components/dashboard/settings.vue b/web/src/components/dashboard/settings.vue new file mode 100644 index 0000000..9250928 --- /dev/null +++ b/web/src/components/dashboard/settings.vue @@ -0,0 +1,547 @@ + + + + + diff --git a/web/src/components/dashboard/support.vue b/web/src/components/dashboard/support.vue new file mode 100644 index 0000000..cdfe28a --- /dev/null +++ b/web/src/components/dashboard/support.vue @@ -0,0 +1,261 @@ + + + + + diff --git a/web/src/components/dashboard/users.vue b/web/src/components/dashboard/users.vue new file mode 100644 index 0000000..bb7a3a9 --- /dev/null +++ b/web/src/components/dashboard/users.vue @@ -0,0 +1,172 @@ + + + + + diff --git a/web/src/components/parts/Footer.vue b/web/src/components/parts/Footer.vue new file mode 100644 index 0000000..283f4f8 --- /dev/null +++ b/web/src/components/parts/Footer.vue @@ -0,0 +1,35 @@ + + + + + diff --git a/web/src/components/parts/Linechart.vue b/web/src/components/parts/Linechart.vue new file mode 100644 index 0000000..cb609fc --- /dev/null +++ b/web/src/components/parts/Linechart.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/web/src/components/parts/Navbar.vue b/web/src/components/parts/Navbar.vue new file mode 100644 index 0000000..daec457 --- /dev/null +++ b/web/src/components/parts/Navbar.vue @@ -0,0 +1,62 @@ + + + + + diff --git a/web/src/components/parts/sidebar.vue b/web/src/components/parts/sidebar.vue new file mode 100644 index 0000000..020921c --- /dev/null +++ b/web/src/components/parts/sidebar.vue @@ -0,0 +1,51 @@ + + + + + diff --git a/web/src/components/user.vue b/web/src/components/user.vue new file mode 100644 index 0000000..7536e5c --- /dev/null +++ b/web/src/components/user.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/web/src/main.ts b/web/src/main.ts new file mode 100644 index 0000000..02670e1 --- /dev/null +++ b/web/src/main.ts @@ -0,0 +1,39 @@ +import { createApp } from 'vue' +import './style.css' +import App from './App.vue' +import Login from './components/Login.vue'; +import User from './components/user.vue'; +import Dashboard from './components/Dashboard.vue'; +import Logs from './components/dashboard/Logs.vue'; +import Actions from './components/dashboard/actions.vue'; +import Users from './components/dashboard/users.vue'; +import Support from './components/dashboard/support.vue'; +import Settings from './components/dashboard/settings.vue'; + +import Home from './components/Home.vue'; + +import { createRouter, createWebHistory } from 'vue-router' + +const router = createRouter({ + // 4. Provide the history implementation to use. We are using the hash history for simplicity here. + history: createWebHistory(), + routes: [ + { path: '/', component: Home }, + { path: '/dash', component: Dashboard }, + { path: '/settings', component: User }, + { path: '/dash/logs', component: Logs }, + { path: '/dash/actions', component: Actions }, + { path: '/dash/users', component: Users }, + { path: '/dash/support', component: Support }, + { path: '/dash/serversettings', component: Settings }, + { path: '/login', component: Login }, + ], +}) + +// 5. Create and mount the root instance. +const app = createApp(App) +// Make sure to _use_ the router instance to make the +// whole app router-aware. +app.use(router) + +app.mount('#app') \ No newline at end of file diff --git a/web/src/style.css b/web/src/style.css new file mode 100644 index 0000000..2e02dcb --- /dev/null +++ b/web/src/style.css @@ -0,0 +1,114 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +body { + background-color: #1e272e; +} + +.centered { + display: flex; + justify-content: center; + align-items: center; +} + +.row { + display: flex; + flex-wrap: wrap +} + +.col-1 { + flex: 0 0 8.33333% +} + +.col-offset-1 { + margin-left: 8.33333% +} + +.col-2 { + flex: 0 0 16.66667% +} + +.col-offset-2 { + margin-left: 16.66667% +} + +.col-3 { + flex: 0 0 25% +} + +.col-offset-3 { + margin-left: 25% +} + +.col-4 { + flex: 0 0 33.33333% +} + +.col-offset-4 { + margin-left: 33.33333% +} + +.col-5 { + flex: 0 0 41.66667% +} + +.col-offset-5 { + margin-left: 41.66667% +} + +.col-6 { + flex: 0 0 50% +} + +.col-offset-6 { + margin-left: 50% +} + +.col-7 { + flex: 0 0 58.33333% +} + +.col-offset-7 { + margin-left: 58.33333% +} + +.col-8 { + flex: 0 0 66.66667% +} + +.col-offset-8 { + margin-left: 66.66667% +} + +.col-9 { + flex: 0 0 75% +} + +.col-offset-9 { + margin-left: 75% +} + +.col-10 { + flex: 0 0 83.33333% +} + +.col-offset-10 { + margin-left: 83.33333% +} + +.col-11 { + flex: 0 0 91.66667% +} + +.col-offset-11 { + margin-left: 91.66667% +} + +.col-12 { + flex: 0 0 100% +} + +.col-offset-12 { + margin-left: 100% +} \ No newline at end of file diff --git a/web/src/vite-env.d.ts b/web/src/vite-env.d.ts new file mode 100644 index 0000000..323c78a --- /dev/null +++ b/web/src/vite-env.d.ts @@ -0,0 +1,7 @@ +/// + +declare module '*.vue' { + import type { DefineComponent } from 'vue' + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/web/tailwind.config.cjs b/web/tailwind.config.cjs new file mode 100644 index 0000000..2638156 --- /dev/null +++ b/web/tailwind.config.cjs @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + "./index.html", + "./src/**/*.{vue,js,ts,jsx,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [require("daisyui")], +} diff --git a/web/tsconfig.json b/web/tsconfig.json new file mode 100644 index 0000000..be20305 --- /dev/null +++ b/web/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "moduleResolution": "Node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "isolatedModules": true, + "esModuleInterop": true, + "lib": ["ESNext", "DOM"], + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue","src/**/**/*.vue"], + "references": [{ "path": "./tsconfig.node.json" }] +} diff --git a/web/tsconfig.node.json b/web/tsconfig.node.json new file mode 100644 index 0000000..9d31e2a --- /dev/null +++ b/web/tsconfig.node.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "composite": true, + "module": "ESNext", + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] +} diff --git a/web/vite.config.ts b/web/vite.config.ts new file mode 100644 index 0000000..315212d --- /dev/null +++ b/web/vite.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [vue()] +})