// SPDX-FileCopyrightText: 2021 The NGI Pointer Secure-Scuttlebutt Team of 2020/2021 // // SPDX-License-Identifier: MIT // Code generated by SQLBoiler 4.5.0 (https://github.com/volatiletech/sqlboiler). DO NOT EDIT. // This file is meant to be re-generated in place and/or deleted at any time. package models import ( "context" "database/sql" "fmt" "reflect" "strings" "sync" "time" "github.com/friendsofgo/errors" "github.com/ssbc/go-ssb-room/v2/roomdb" "github.com/volatiletech/sqlboiler/v4/boil" "github.com/volatiletech/sqlboiler/v4/queries" "github.com/volatiletech/sqlboiler/v4/queries/qm" "github.com/volatiletech/sqlboiler/v4/queries/qmhelper" "github.com/volatiletech/strmangle" ) // DeniedKey is an object representing the database table. type DeniedKey struct { ID int64 `boil:"id" json:"id" toml:"id" yaml:"id"` PubKey roomdb.DBFeedRef `boil:"pub_key" json:"pub_key" toml:"pub_key" yaml:"pub_key"` Comment string `boil:"comment" json:"comment" toml:"comment" yaml:"comment"` CreatedAt time.Time `boil:"created_at" json:"created_at" toml:"created_at" yaml:"created_at"` R *deniedKeyR `boil:"-" json:"-" toml:"-" yaml:"-"` L deniedKeyL `boil:"-" json:"-" toml:"-" yaml:"-"` } var DeniedKeyColumns = struct { ID string PubKey string Comment string CreatedAt string }{ ID: "id", PubKey: "pub_key", Comment: "comment", CreatedAt: "created_at", } // Generated where type whereHelperroomdb_DBFeedRef struct{ field string } func (w whereHelperroomdb_DBFeedRef) EQ(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.EQ, x) } func (w whereHelperroomdb_DBFeedRef) NEQ(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.NEQ, x) } func (w whereHelperroomdb_DBFeedRef) LT(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LT, x) } func (w whereHelperroomdb_DBFeedRef) LTE(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.LTE, x) } func (w whereHelperroomdb_DBFeedRef) GT(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GT, x) } func (w whereHelperroomdb_DBFeedRef) GTE(x roomdb.DBFeedRef) qm.QueryMod { return qmhelper.Where(w.field, qmhelper.GTE, x) } var DeniedKeyWhere = struct { ID whereHelperint64 PubKey whereHelperroomdb_DBFeedRef Comment whereHelperstring CreatedAt whereHelpertime_Time }{ ID: whereHelperint64{field: "\"denied_keys\".\"id\""}, PubKey: whereHelperroomdb_DBFeedRef{field: "\"denied_keys\".\"pub_key\""}, Comment: whereHelperstring{field: "\"denied_keys\".\"comment\""}, CreatedAt: whereHelpertime_Time{field: "\"denied_keys\".\"created_at\""}, } // DeniedKeyRels is where relationship names are stored. var DeniedKeyRels = struct { }{} // deniedKeyR is where relationships are stored. type deniedKeyR struct { } // NewStruct creates a new relationship struct func (*deniedKeyR) NewStruct() *deniedKeyR { return &deniedKeyR{} } // deniedKeyL is where Load methods for each relationship are stored. type deniedKeyL struct{} var ( deniedKeyAllColumns = []string{"id", "pub_key", "comment", "created_at"} deniedKeyColumnsWithoutDefault = []string{} deniedKeyColumnsWithDefault = []string{"id", "pub_key", "comment", "created_at"} deniedKeyPrimaryKeyColumns = []string{"id"} ) type ( // DeniedKeySlice is an alias for a slice of pointers to DeniedKey. // This should generally be used opposed to []DeniedKey. DeniedKeySlice []*DeniedKey // DeniedKeyHook is the signature for custom DeniedKey hook methods DeniedKeyHook func(context.Context, boil.ContextExecutor, *DeniedKey) error deniedKeyQuery struct { *queries.Query } ) // Cache for insert, update and upsert var ( deniedKeyType = reflect.TypeOf(&DeniedKey{}) deniedKeyMapping = queries.MakeStructMapping(deniedKeyType) deniedKeyPrimaryKeyMapping, _ = queries.BindMapping(deniedKeyType, deniedKeyMapping, deniedKeyPrimaryKeyColumns) deniedKeyInsertCacheMut sync.RWMutex deniedKeyInsertCache = make(map[string]insertCache) deniedKeyUpdateCacheMut sync.RWMutex deniedKeyUpdateCache = make(map[string]updateCache) deniedKeyUpsertCacheMut sync.RWMutex deniedKeyUpsertCache = make(map[string]insertCache) ) var ( // Force time package dependency for automated UpdatedAt/CreatedAt. _ = time.Second // Force qmhelper dependency for where clause generation (which doesn't // always happen) _ = qmhelper.Where ) var deniedKeyBeforeInsertHooks []DeniedKeyHook var deniedKeyBeforeUpdateHooks []DeniedKeyHook var deniedKeyBeforeDeleteHooks []DeniedKeyHook var deniedKeyBeforeUpsertHooks []DeniedKeyHook var deniedKeyAfterInsertHooks []DeniedKeyHook var deniedKeyAfterSelectHooks []DeniedKeyHook var deniedKeyAfterUpdateHooks []DeniedKeyHook var deniedKeyAfterDeleteHooks []DeniedKeyHook var deniedKeyAfterUpsertHooks []DeniedKeyHook // doBeforeInsertHooks executes all "before insert" hooks. func (o *DeniedKey) doBeforeInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyBeforeInsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeUpdateHooks executes all "before Update" hooks. func (o *DeniedKey) doBeforeUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyBeforeUpdateHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeDeleteHooks executes all "before Delete" hooks. func (o *DeniedKey) doBeforeDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyBeforeDeleteHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doBeforeUpsertHooks executes all "before Upsert" hooks. func (o *DeniedKey) doBeforeUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyBeforeUpsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterInsertHooks executes all "after Insert" hooks. func (o *DeniedKey) doAfterInsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyAfterInsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterSelectHooks executes all "after Select" hooks. func (o *DeniedKey) doAfterSelectHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyAfterSelectHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterUpdateHooks executes all "after Update" hooks. func (o *DeniedKey) doAfterUpdateHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyAfterUpdateHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterDeleteHooks executes all "after Delete" hooks. func (o *DeniedKey) doAfterDeleteHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyAfterDeleteHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // doAfterUpsertHooks executes all "after Upsert" hooks. func (o *DeniedKey) doAfterUpsertHooks(ctx context.Context, exec boil.ContextExecutor) (err error) { if boil.HooksAreSkipped(ctx) { return nil } for _, hook := range deniedKeyAfterUpsertHooks { if err := hook(ctx, exec, o); err != nil { return err } } return nil } // AddDeniedKeyHook registers your hook function for all future operations. func AddDeniedKeyHook(hookPoint boil.HookPoint, deniedKeyHook DeniedKeyHook) { switch hookPoint { case boil.BeforeInsertHook: deniedKeyBeforeInsertHooks = append(deniedKeyBeforeInsertHooks, deniedKeyHook) case boil.BeforeUpdateHook: deniedKeyBeforeUpdateHooks = append(deniedKeyBeforeUpdateHooks, deniedKeyHook) case boil.BeforeDeleteHook: deniedKeyBeforeDeleteHooks = append(deniedKeyBeforeDeleteHooks, deniedKeyHook) case boil.BeforeUpsertHook: deniedKeyBeforeUpsertHooks = append(deniedKeyBeforeUpsertHooks, deniedKeyHook) case boil.AfterInsertHook: deniedKeyAfterInsertHooks = append(deniedKeyAfterInsertHooks, deniedKeyHook) case boil.AfterSelectHook: deniedKeyAfterSelectHooks = append(deniedKeyAfterSelectHooks, deniedKeyHook) case boil.AfterUpdateHook: deniedKeyAfterUpdateHooks = append(deniedKeyAfterUpdateHooks, deniedKeyHook) case boil.AfterDeleteHook: deniedKeyAfterDeleteHooks = append(deniedKeyAfterDeleteHooks, deniedKeyHook) case boil.AfterUpsertHook: deniedKeyAfterUpsertHooks = append(deniedKeyAfterUpsertHooks, deniedKeyHook) } } // One returns a single deniedKey record from the query. func (q deniedKeyQuery) One(ctx context.Context, exec boil.ContextExecutor) (*DeniedKey, error) { o := &DeniedKey{} queries.SetLimit(q.Query, 1) err := q.Bind(ctx, exec, o) if err != nil { if errors.Cause(err) == sql.ErrNoRows { return nil, sql.ErrNoRows } return nil, errors.Wrap(err, "models: failed to execute a one query for denied_keys") } if err := o.doAfterSelectHooks(ctx, exec); err != nil { return o, err } return o, nil } // All returns all DeniedKey records from the query. func (q deniedKeyQuery) All(ctx context.Context, exec boil.ContextExecutor) (DeniedKeySlice, error) { var o []*DeniedKey err := q.Bind(ctx, exec, &o) if err != nil { return nil, errors.Wrap(err, "models: failed to assign all query results to DeniedKey slice") } if len(deniedKeyAfterSelectHooks) != 0 { for _, obj := range o { if err := obj.doAfterSelectHooks(ctx, exec); err != nil { return o, err } } } return o, nil } // Count returns the count of all DeniedKey records in the query. func (q deniedKeyQuery) Count(ctx context.Context, exec boil.ContextExecutor) (int64, error) { var count int64 queries.SetSelect(q.Query, nil) queries.SetCount(q.Query) err := q.Query.QueryRowContext(ctx, exec).Scan(&count) if err != nil { return 0, errors.Wrap(err, "models: failed to count denied_keys rows") } return count, nil } // Exists checks if the row exists in the table. func (q deniedKeyQuery) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) { var count int64 queries.SetSelect(q.Query, nil) queries.SetCount(q.Query) queries.SetLimit(q.Query, 1) err := q.Query.QueryRowContext(ctx, exec).Scan(&count) if err != nil { return false, errors.Wrap(err, "models: failed to check if denied_keys exists") } return count > 0, nil } // DeniedKeys retrieves all the records using an executor. func DeniedKeys(mods ...qm.QueryMod) deniedKeyQuery { mods = append(mods, qm.From("\"denied_keys\"")) return deniedKeyQuery{NewQuery(mods...)} } // FindDeniedKey retrieves a single record by ID with an executor. // If selectCols is empty Find will return all columns. func FindDeniedKey(ctx context.Context, exec boil.ContextExecutor, iD int64, selectCols ...string) (*DeniedKey, error) { deniedKeyObj := &DeniedKey{} sel := "*" if len(selectCols) > 0 { sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",") } query := fmt.Sprintf( "select %s from \"denied_keys\" where \"id\"=?", sel, ) q := queries.Raw(query, iD) err := q.Bind(ctx, exec, deniedKeyObj) if err != nil { if errors.Cause(err) == sql.ErrNoRows { return nil, sql.ErrNoRows } return nil, errors.Wrap(err, "models: unable to select from denied_keys") } return deniedKeyObj, nil } // Insert a single record using an executor. // See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts. func (o *DeniedKey) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error { if o == nil { return errors.New("models: no denied_keys provided for insertion") } var err error if !boil.TimestampsAreSkipped(ctx) { currTime := time.Now().In(boil.GetLocation()) if o.CreatedAt.IsZero() { o.CreatedAt = currTime } } if err := o.doBeforeInsertHooks(ctx, exec); err != nil { return err } nzDefaults := queries.NonZeroDefaultSet(deniedKeyColumnsWithDefault, o) key := makeCacheKey(columns, nzDefaults) deniedKeyInsertCacheMut.RLock() cache, cached := deniedKeyInsertCache[key] deniedKeyInsertCacheMut.RUnlock() if !cached { wl, returnColumns := columns.InsertColumnSet( deniedKeyAllColumns, deniedKeyColumnsWithDefault, deniedKeyColumnsWithoutDefault, nzDefaults, ) cache.valueMapping, err = queries.BindMapping(deniedKeyType, deniedKeyMapping, wl) if err != nil { return err } cache.retMapping, err = queries.BindMapping(deniedKeyType, deniedKeyMapping, returnColumns) if err != nil { return err } if len(wl) != 0 { cache.query = fmt.Sprintf("INSERT INTO \"denied_keys\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1)) } else { cache.query = "INSERT INTO \"denied_keys\" %sDEFAULT VALUES%s" } var queryOutput, queryReturning string if len(cache.retMapping) != 0 { cache.retQuery = fmt.Sprintf("SELECT \"%s\" FROM \"denied_keys\" WHERE %s", strings.Join(returnColumns, "\",\""), strmangle.WhereClause("\"", "\"", 0, deniedKeyPrimaryKeyColumns)) } cache.query = fmt.Sprintf(cache.query, queryOutput, queryReturning) } value := reflect.Indirect(reflect.ValueOf(o)) vals := queries.ValuesFromMapping(value, cache.valueMapping) if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, cache.query) fmt.Fprintln(writer, vals) } result, err := exec.ExecContext(ctx, cache.query, vals...) if err != nil { return errors.Wrap(err, "models: unable to insert into denied_keys") } var lastID int64 var identifierCols []interface{} if len(cache.retMapping) == 0 { goto CacheNoHooks } lastID, err = result.LastInsertId() if err != nil { return ErrSyncFail } o.ID = int64(lastID) if lastID != 0 && len(cache.retMapping) == 1 && cache.retMapping[0] == deniedKeyMapping["id"] { goto CacheNoHooks } identifierCols = []interface{}{ o.ID, } if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, cache.retQuery) fmt.Fprintln(writer, identifierCols...) } err = exec.QueryRowContext(ctx, cache.retQuery, identifierCols...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...) if err != nil { return errors.Wrap(err, "models: unable to populate default values for denied_keys") } CacheNoHooks: if !cached { deniedKeyInsertCacheMut.Lock() deniedKeyInsertCache[key] = cache deniedKeyInsertCacheMut.Unlock() } return o.doAfterInsertHooks(ctx, exec) } // Update uses an executor to update the DeniedKey. // See boil.Columns.UpdateColumnSet documentation to understand column list inference for updates. // Update does not automatically update the record in case of default values. Use .Reload() to refresh the records. func (o *DeniedKey) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error) { var err error if err = o.doBeforeUpdateHooks(ctx, exec); err != nil { return 0, err } key := makeCacheKey(columns, nil) deniedKeyUpdateCacheMut.RLock() cache, cached := deniedKeyUpdateCache[key] deniedKeyUpdateCacheMut.RUnlock() if !cached { wl := columns.UpdateColumnSet( deniedKeyAllColumns, deniedKeyPrimaryKeyColumns, ) if !columns.IsWhitelist() { wl = strmangle.SetComplement(wl, []string{"created_at"}) } if len(wl) == 0 { return 0, errors.New("models: unable to update denied_keys, could not build whitelist") } cache.query = fmt.Sprintf("UPDATE \"denied_keys\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 0, wl), strmangle.WhereClause("\"", "\"", 0, deniedKeyPrimaryKeyColumns), ) cache.valueMapping, err = queries.BindMapping(deniedKeyType, deniedKeyMapping, append(wl, deniedKeyPrimaryKeyColumns...)) if err != nil { return 0, err } } values := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), cache.valueMapping) if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, cache.query) fmt.Fprintln(writer, values) } var result sql.Result result, err = exec.ExecContext(ctx, cache.query, values...) if err != nil { return 0, errors.Wrap(err, "models: unable to update denied_keys row") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: failed to get rows affected by update for denied_keys") } if !cached { deniedKeyUpdateCacheMut.Lock() deniedKeyUpdateCache[key] = cache deniedKeyUpdateCacheMut.Unlock() } return rowsAff, o.doAfterUpdateHooks(ctx, exec) } // UpdateAll updates all rows with the specified column values. func (q deniedKeyQuery) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { queries.SetUpdate(q.Query, cols) result, err := q.Query.ExecContext(ctx, exec) if err != nil { return 0, errors.Wrap(err, "models: unable to update all for denied_keys") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: unable to retrieve rows affected for denied_keys") } return rowsAff, nil } // UpdateAll updates all rows with the specified column values, using an executor. func (o DeniedKeySlice) UpdateAll(ctx context.Context, exec boil.ContextExecutor, cols M) (int64, error) { ln := int64(len(o)) if ln == 0 { return 0, nil } if len(cols) == 0 { return 0, errors.New("models: update all requires at least one column argument") } colNames := make([]string, len(cols)) args := make([]interface{}, len(cols)) i := 0 for name, value := range cols { colNames[i] = name args[i] = value i++ } // Append all of the primary key values for each column for _, obj := range o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), deniedKeyPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := fmt.Sprintf("UPDATE \"denied_keys\" SET %s WHERE %s", strmangle.SetParamNames("\"", "\"", 0, colNames), strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, deniedKeyPrimaryKeyColumns, len(o))) if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, sql) fmt.Fprintln(writer, args...) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "models: unable to update all in deniedKey slice") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: unable to retrieve rows affected all in update all deniedKey") } return rowsAff, nil } // Delete deletes a single DeniedKey record with an executor. // Delete will match against the primary key column to find the record to delete. func (o *DeniedKey) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if o == nil { return 0, errors.New("models: no DeniedKey provided for delete") } if err := o.doBeforeDeleteHooks(ctx, exec); err != nil { return 0, err } args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), deniedKeyPrimaryKeyMapping) sql := "DELETE FROM \"denied_keys\" WHERE \"id\"=?" if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, sql) fmt.Fprintln(writer, args...) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "models: unable to delete from denied_keys") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: failed to get rows affected by delete for denied_keys") } if err := o.doAfterDeleteHooks(ctx, exec); err != nil { return 0, err } return rowsAff, nil } // DeleteAll deletes all matching rows. func (q deniedKeyQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if q.Query == nil { return 0, errors.New("models: no deniedKeyQuery provided for delete all") } queries.SetDelete(q.Query) result, err := q.Query.ExecContext(ctx, exec) if err != nil { return 0, errors.Wrap(err, "models: unable to delete all from denied_keys") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: failed to get rows affected by deleteall for denied_keys") } return rowsAff, nil } // DeleteAll deletes all rows in the slice, using an executor. func (o DeniedKeySlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) { if len(o) == 0 { return 0, nil } if len(deniedKeyBeforeDeleteHooks) != 0 { for _, obj := range o { if err := obj.doBeforeDeleteHooks(ctx, exec); err != nil { return 0, err } } } var args []interface{} for _, obj := range o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), deniedKeyPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := "DELETE FROM \"denied_keys\" WHERE " + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, deniedKeyPrimaryKeyColumns, len(o)) if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, sql) fmt.Fprintln(writer, args) } result, err := exec.ExecContext(ctx, sql, args...) if err != nil { return 0, errors.Wrap(err, "models: unable to delete all from deniedKey slice") } rowsAff, err := result.RowsAffected() if err != nil { return 0, errors.Wrap(err, "models: failed to get rows affected by deleteall for denied_keys") } if len(deniedKeyAfterDeleteHooks) != 0 { for _, obj := range o { if err := obj.doAfterDeleteHooks(ctx, exec); err != nil { return 0, err } } } return rowsAff, nil } // Reload refetches the object from the database // using the primary keys with an executor. func (o *DeniedKey) Reload(ctx context.Context, exec boil.ContextExecutor) error { ret, err := FindDeniedKey(ctx, exec, o.ID) if err != nil { return err } *o = *ret return nil } // ReloadAll refetches every row with matching primary key column values // and overwrites the original object slice with the newly updated slice. func (o *DeniedKeySlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error { if o == nil || len(*o) == 0 { return nil } slice := DeniedKeySlice{} var args []interface{} for _, obj := range *o { pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), deniedKeyPrimaryKeyMapping) args = append(args, pkeyArgs...) } sql := "SELECT \"denied_keys\".* FROM \"denied_keys\" WHERE " + strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, deniedKeyPrimaryKeyColumns, len(*o)) q := queries.Raw(sql, args...) err := q.Bind(ctx, exec, &slice) if err != nil { return errors.Wrap(err, "models: unable to reload all in DeniedKeySlice") } *o = slice return nil } // DeniedKeyExists checks if the DeniedKey row exists. func DeniedKeyExists(ctx context.Context, exec boil.ContextExecutor, iD int64) (bool, error) { var exists bool sql := "select exists(select 1 from \"denied_keys\" where \"id\"=? limit 1)" if boil.IsDebug(ctx) { writer := boil.DebugWriterFrom(ctx) fmt.Fprintln(writer, sql) fmt.Fprintln(writer, iD) } row := exec.QueryRowContext(ctx, sql, iD) err := row.Scan(&exists) if err != nil { return false, errors.Wrap(err, "models: unable to check if denied_keys exists") } return exists, nil }