desktop/backend/model/transaction_importer.go
// Code generated by SQLBoiler 4.15.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 model
import (
"context"
"database/sql"
"fmt"
"reflect"
"strconv"
"strings"
"sync"
"time"
"github.com/friendsofgo/errors"
"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"
)
// TransactionImporter is an object representing the database table.
type TransactionImporter struct {
ID int64 `boil:"id" json:"id" toml:"id" yaml:"id"`
StatusID int64 `boil:"status_id" json:"status_id" toml:"status_id" yaml:"status_id"`
Filename string `boil:"filename" json:"filename" toml:"filename" yaml:"filename"`
Filesize int64 `boil:"filesize" json:"filesize" toml:"filesize" yaml:"filesize"`
Checksum string `boil:"checksum" json:"checksum" toml:"checksum" yaml:"checksum"`
DateCreated string `boil:"date_created" json:"date_created" toml:"date_created" yaml:"date_created"`
DateImported string `boil:"date_imported" json:"date_imported" toml:"date_imported" yaml:"date_imported"`
R *transactionImporterR `boil:"-" json:"-" toml:"-" yaml:"-"`
L transactionImporterL `boil:"-" json:"-" toml:"-" yaml:"-"`
}
var TransactionImporterColumns = struct {
ID string
StatusID string
Filename string
Filesize string
Checksum string
DateCreated string
DateImported string
}{
ID: "id",
StatusID: "status_id",
Filename: "filename",
Filesize: "filesize",
Checksum: "checksum",
DateCreated: "date_created",
DateImported: "date_imported",
}
var TransactionImporterTableColumns = struct {
ID string
StatusID string
Filename string
Filesize string
Checksum string
DateCreated string
DateImported string
}{
ID: "transaction_importer.id",
StatusID: "transaction_importer.status_id",
Filename: "transaction_importer.filename",
Filesize: "transaction_importer.filesize",
Checksum: "transaction_importer.checksum",
DateCreated: "transaction_importer.date_created",
DateImported: "transaction_importer.date_imported",
}
// Generated where
var TransactionImporterWhere = struct {
ID whereHelperint64
StatusID whereHelperint64
Filename whereHelperstring
Filesize whereHelperint64
Checksum whereHelperstring
DateCreated whereHelperstring
DateImported whereHelperstring
}{
ID: whereHelperint64{field: "\"transaction_importer\".\"id\""},
StatusID: whereHelperint64{field: "\"transaction_importer\".\"status_id\""},
Filename: whereHelperstring{field: "\"transaction_importer\".\"filename\""},
Filesize: whereHelperint64{field: "\"transaction_importer\".\"filesize\""},
Checksum: whereHelperstring{field: "\"transaction_importer\".\"checksum\""},
DateCreated: whereHelperstring{field: "\"transaction_importer\".\"date_created\""},
DateImported: whereHelperstring{field: "\"transaction_importer\".\"date_imported\""},
}
// TransactionImporterRels is where relationship names are stored.
var TransactionImporterRels = struct {
Status string
}{
Status: "Status",
}
// transactionImporterR is where relationships are stored.
type transactionImporterR struct {
Status *TransactionImporterStatus `boil:"Status" json:"Status" toml:"Status" yaml:"Status"`
}
// NewStruct creates a new relationship struct
func (*transactionImporterR) NewStruct() *transactionImporterR {
return &transactionImporterR{}
}
func (r *transactionImporterR) GetStatus() *TransactionImporterStatus {
if r == nil {
return nil
}
return r.Status
}
// transactionImporterL is where Load methods for each relationship are stored.
type transactionImporterL struct{}
var (
transactionImporterAllColumns = []string{"id", "status_id", "filename", "filesize", "checksum", "date_created", "date_imported"}
transactionImporterColumnsWithoutDefault = []string{"status_id", "filename", "filesize", "checksum", "date_created", "date_imported"}
transactionImporterColumnsWithDefault = []string{"id"}
transactionImporterPrimaryKeyColumns = []string{"id"}
transactionImporterGeneratedColumns = []string{"id"}
)
type (
// TransactionImporterSlice is an alias for a slice of pointers to TransactionImporter.
// This should almost always be used instead of []TransactionImporter.
TransactionImporterSlice []*TransactionImporter
transactionImporterQuery struct {
*queries.Query
}
)
// Cache for insert, update and upsert
var (
transactionImporterType = reflect.TypeOf(&TransactionImporter{})
transactionImporterMapping = queries.MakeStructMapping(transactionImporterType)
transactionImporterPrimaryKeyMapping, _ = queries.BindMapping(transactionImporterType, transactionImporterMapping, transactionImporterPrimaryKeyColumns)
transactionImporterInsertCacheMut sync.RWMutex
transactionImporterInsertCache = make(map[string]insertCache)
transactionImporterUpdateCacheMut sync.RWMutex
transactionImporterUpdateCache = make(map[string]updateCache)
transactionImporterUpsertCacheMut sync.RWMutex
transactionImporterUpsertCache = 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
)
// One returns a single transactionImporter record from the query.
func (q transactionImporterQuery) One(ctx context.Context, exec boil.ContextExecutor) (*TransactionImporter, error) {
o := &TransactionImporter{}
queries.SetLimit(q.Query, 1)
err := q.Bind(ctx, exec, o)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, sql.ErrNoRows
}
return nil, errors.Wrap(err, "model: failed to execute a one query for transaction_importer")
}
return o, nil
}
// All returns all TransactionImporter records from the query.
func (q transactionImporterQuery) All(ctx context.Context, exec boil.ContextExecutor) (TransactionImporterSlice, error) {
var o []*TransactionImporter
err := q.Bind(ctx, exec, &o)
if err != nil {
return nil, errors.Wrap(err, "model: failed to assign all query results to TransactionImporter slice")
}
return o, nil
}
// Count returns the count of all TransactionImporter records in the query.
func (q transactionImporterQuery) 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, "model: failed to count transaction_importer rows")
}
return count, nil
}
// Exists checks if the row exists in the table.
func (q transactionImporterQuery) 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, "model: failed to check if transaction_importer exists")
}
return count > 0, nil
}
// Status pointed to by the foreign key.
func (o *TransactionImporter) Status(mods ...qm.QueryMod) transactionImporterStatusQuery {
queryMods := []qm.QueryMod{
qm.Where("\"id\" = ?", o.StatusID),
}
queryMods = append(queryMods, mods...)
return TransactionImporterStatuses(queryMods...)
}
// LoadStatus allows an eager lookup of values, cached into the
// loaded structs of the objects. This is for an N-1 relationship.
func (transactionImporterL) LoadStatus(ctx context.Context, e boil.ContextExecutor, singular bool, maybeTransactionImporter interface{}, mods queries.Applicator) error {
var slice []*TransactionImporter
var object *TransactionImporter
if singular {
var ok bool
object, ok = maybeTransactionImporter.(*TransactionImporter)
if !ok {
object = new(TransactionImporter)
ok = queries.SetFromEmbeddedStruct(&object, &maybeTransactionImporter)
if !ok {
return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", object, maybeTransactionImporter))
}
}
} else {
s, ok := maybeTransactionImporter.(*[]*TransactionImporter)
if ok {
slice = *s
} else {
ok = queries.SetFromEmbeddedStruct(&slice, maybeTransactionImporter)
if !ok {
return errors.New(fmt.Sprintf("failed to set %T from embedded struct %T", slice, maybeTransactionImporter))
}
}
}
args := make([]interface{}, 0, 1)
if singular {
if object.R == nil {
object.R = &transactionImporterR{}
}
args = append(args, object.StatusID)
} else {
Outer:
for _, obj := range slice {
if obj.R == nil {
obj.R = &transactionImporterR{}
}
for _, a := range args {
if a == obj.StatusID {
continue Outer
}
}
args = append(args, obj.StatusID)
}
}
if len(args) == 0 {
return nil
}
query := NewQuery(
qm.From(`transaction_importer_status`),
qm.WhereIn(`transaction_importer_status.id in ?`, args...),
)
if mods != nil {
mods.Apply(query)
}
results, err := query.QueryContext(ctx, e)
if err != nil {
return errors.Wrap(err, "failed to eager load TransactionImporterStatus")
}
var resultSlice []*TransactionImporterStatus
if err = queries.Bind(results, &resultSlice); err != nil {
return errors.Wrap(err, "failed to bind eager loaded slice TransactionImporterStatus")
}
if err = results.Close(); err != nil {
return errors.Wrap(err, "failed to close results of eager load for transaction_importer_status")
}
if err = results.Err(); err != nil {
return errors.Wrap(err, "error occurred during iteration of eager loaded relations for transaction_importer_status")
}
if len(resultSlice) == 0 {
return nil
}
if singular {
foreign := resultSlice[0]
object.R.Status = foreign
if foreign.R == nil {
foreign.R = &transactionImporterStatusR{}
}
foreign.R.StatusTransactionImporters = append(foreign.R.StatusTransactionImporters, object)
return nil
}
for _, local := range slice {
for _, foreign := range resultSlice {
if local.StatusID == foreign.ID {
local.R.Status = foreign
if foreign.R == nil {
foreign.R = &transactionImporterStatusR{}
}
foreign.R.StatusTransactionImporters = append(foreign.R.StatusTransactionImporters, local)
break
}
}
}
return nil
}
// SetStatus of the transactionImporter to the related item.
// Sets o.R.Status to related.
// Adds o to related.R.StatusTransactionImporters.
func (o *TransactionImporter) SetStatus(ctx context.Context, exec boil.ContextExecutor, insert bool, related *TransactionImporterStatus) error {
var err error
if insert {
if err = related.Insert(ctx, exec, boil.Infer()); err != nil {
return errors.Wrap(err, "failed to insert into foreign table")
}
}
updateQuery := fmt.Sprintf(
"UPDATE \"transaction_importer\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 0, []string{"status_id"}),
strmangle.WhereClause("\"", "\"", 0, transactionImporterPrimaryKeyColumns),
)
values := []interface{}{related.ID, o.ID}
if boil.IsDebug(ctx) {
writer := boil.DebugWriterFrom(ctx)
fmt.Fprintln(writer, updateQuery)
fmt.Fprintln(writer, values)
}
if _, err = exec.ExecContext(ctx, updateQuery, values...); err != nil {
return errors.Wrap(err, "failed to update local table")
}
o.StatusID = related.ID
if o.R == nil {
o.R = &transactionImporterR{
Status: related,
}
} else {
o.R.Status = related
}
if related.R == nil {
related.R = &transactionImporterStatusR{
StatusTransactionImporters: TransactionImporterSlice{o},
}
} else {
related.R.StatusTransactionImporters = append(related.R.StatusTransactionImporters, o)
}
return nil
}
// TransactionImporters retrieves all the records using an executor.
func TransactionImporters(mods ...qm.QueryMod) transactionImporterQuery {
mods = append(mods, qm.From("\"transaction_importer\""))
q := NewQuery(mods...)
if len(queries.GetSelect(q)) == 0 {
queries.SetSelect(q, []string{"\"transaction_importer\".*"})
}
return transactionImporterQuery{q}
}
// FindTransactionImporter retrieves a single record by ID with an executor.
// If selectCols is empty Find will return all columns.
func FindTransactionImporter(ctx context.Context, exec boil.ContextExecutor, iD int64, selectCols ...string) (*TransactionImporter, error) {
transactionImporterObj := &TransactionImporter{}
sel := "*"
if len(selectCols) > 0 {
sel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), ",")
}
query := fmt.Sprintf(
"select %s from \"transaction_importer\" where \"id\"=?", sel,
)
q := queries.Raw(query, iD)
err := q.Bind(ctx, exec, transactionImporterObj)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, sql.ErrNoRows
}
return nil, errors.Wrap(err, "model: unable to select from transaction_importer")
}
return transactionImporterObj, nil
}
// Insert a single record using an executor.
// See boil.Columns.InsertColumnSet documentation to understand column list inference for inserts.
func (o *TransactionImporter) Insert(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) error {
if o == nil {
return errors.New("model: no transaction_importer provided for insertion")
}
var err error
nzDefaults := queries.NonZeroDefaultSet(transactionImporterColumnsWithDefault, o)
key := makeCacheKey(columns, nzDefaults)
transactionImporterInsertCacheMut.RLock()
cache, cached := transactionImporterInsertCache[key]
transactionImporterInsertCacheMut.RUnlock()
if !cached {
wl, returnColumns := columns.InsertColumnSet(
transactionImporterAllColumns,
transactionImporterColumnsWithDefault,
transactionImporterColumnsWithoutDefault,
nzDefaults,
)
wl = strmangle.SetComplement(wl, transactionImporterGeneratedColumns)
cache.valueMapping, err = queries.BindMapping(transactionImporterType, transactionImporterMapping, wl)
if err != nil {
return err
}
cache.retMapping, err = queries.BindMapping(transactionImporterType, transactionImporterMapping, returnColumns)
if err != nil {
return err
}
if len(wl) != 0 {
cache.query = fmt.Sprintf("INSERT INTO \"transaction_importer\" (\"%s\") %%sVALUES (%s)%%s", strings.Join(wl, "\",\""), strmangle.Placeholders(dialect.UseIndexPlaceholders, len(wl), 1, 1))
} else {
cache.query = "INSERT INTO \"transaction_importer\" %sDEFAULT VALUES%s"
}
var queryOutput, queryReturning string
if len(cache.retMapping) != 0 {
queryReturning = fmt.Sprintf(" RETURNING \"%s\"", strings.Join(returnColumns, "\",\""))
}
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)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(queries.PtrsFromMapping(value, cache.retMapping)...)
} else {
_, err = exec.ExecContext(ctx, cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "model: unable to insert into transaction_importer")
}
if !cached {
transactionImporterInsertCacheMut.Lock()
transactionImporterInsertCache[key] = cache
transactionImporterInsertCacheMut.Unlock()
}
return nil
}
// Update uses an executor to update the TransactionImporter.
// 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 *TransactionImporter) Update(ctx context.Context, exec boil.ContextExecutor, columns boil.Columns) (int64, error) {
var err error
key := makeCacheKey(columns, nil)
transactionImporterUpdateCacheMut.RLock()
cache, cached := transactionImporterUpdateCache[key]
transactionImporterUpdateCacheMut.RUnlock()
if !cached {
wl := columns.UpdateColumnSet(
transactionImporterAllColumns,
transactionImporterPrimaryKeyColumns,
)
wl = strmangle.SetComplement(wl, transactionImporterGeneratedColumns)
if len(wl) == 0 {
return 0, errors.New("model: unable to update transaction_importer, could not build whitelist")
}
cache.query = fmt.Sprintf("UPDATE \"transaction_importer\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 0, wl),
strmangle.WhereClause("\"", "\"", 0, transactionImporterPrimaryKeyColumns),
)
cache.valueMapping, err = queries.BindMapping(transactionImporterType, transactionImporterMapping, append(wl, transactionImporterPrimaryKeyColumns...))
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, "model: unable to update transaction_importer row")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: failed to get rows affected by update for transaction_importer")
}
if !cached {
transactionImporterUpdateCacheMut.Lock()
transactionImporterUpdateCache[key] = cache
transactionImporterUpdateCacheMut.Unlock()
}
return rowsAff, nil
}
// UpdateAll updates all rows with the specified column values.
func (q transactionImporterQuery) 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, "model: unable to update all for transaction_importer")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: unable to retrieve rows affected for transaction_importer")
}
return rowsAff, nil
}
// UpdateAll updates all rows with the specified column values, using an executor.
func (o TransactionImporterSlice) 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("model: 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)), transactionImporterPrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := fmt.Sprintf("UPDATE \"transaction_importer\" SET %s WHERE %s",
strmangle.SetParamNames("\"", "\"", 0, colNames),
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, transactionImporterPrimaryKeyColumns, 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, "model: unable to update all in transactionImporter slice")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: unable to retrieve rows affected all in update all transactionImporter")
}
return rowsAff, nil
}
// Upsert attempts an insert using an executor, and does an update or ignore on conflict.
// See boil.Columns documentation for how to properly use updateColumns and insertColumns.
func (o *TransactionImporter) Upsert(ctx context.Context, exec boil.ContextExecutor, updateOnConflict bool, conflictColumns []string, updateColumns, insertColumns boil.Columns) error {
if o == nil {
return errors.New("model: no transaction_importer provided for upsert")
}
nzDefaults := queries.NonZeroDefaultSet(transactionImporterColumnsWithDefault, o)
// Build cache key in-line uglily - mysql vs psql problems
buf := strmangle.GetBuffer()
if updateOnConflict {
buf.WriteByte('t')
} else {
buf.WriteByte('f')
}
buf.WriteByte('.')
for _, c := range conflictColumns {
buf.WriteString(c)
}
buf.WriteByte('.')
buf.WriteString(strconv.Itoa(updateColumns.Kind))
for _, c := range updateColumns.Cols {
buf.WriteString(c)
}
buf.WriteByte('.')
buf.WriteString(strconv.Itoa(insertColumns.Kind))
for _, c := range insertColumns.Cols {
buf.WriteString(c)
}
buf.WriteByte('.')
for _, c := range nzDefaults {
buf.WriteString(c)
}
key := buf.String()
strmangle.PutBuffer(buf)
transactionImporterUpsertCacheMut.RLock()
cache, cached := transactionImporterUpsertCache[key]
transactionImporterUpsertCacheMut.RUnlock()
var err error
if !cached {
insert, ret := insertColumns.InsertColumnSet(
transactionImporterAllColumns,
transactionImporterColumnsWithDefault,
transactionImporterColumnsWithoutDefault,
nzDefaults,
)
update := updateColumns.UpdateColumnSet(
transactionImporterAllColumns,
transactionImporterPrimaryKeyColumns,
)
if updateOnConflict && len(update) == 0 {
return errors.New("model: unable to upsert transaction_importer, could not build update column list")
}
conflict := conflictColumns
if len(conflict) == 0 {
conflict = make([]string, len(transactionImporterPrimaryKeyColumns))
copy(conflict, transactionImporterPrimaryKeyColumns)
}
cache.query = buildUpsertQuerySQLite(dialect, "\"transaction_importer\"", updateOnConflict, ret, update, conflict, insert)
cache.valueMapping, err = queries.BindMapping(transactionImporterType, transactionImporterMapping, insert)
if err != nil {
return err
}
if len(ret) != 0 {
cache.retMapping, err = queries.BindMapping(transactionImporterType, transactionImporterMapping, ret)
if err != nil {
return err
}
}
}
value := reflect.Indirect(reflect.ValueOf(o))
vals := queries.ValuesFromMapping(value, cache.valueMapping)
var returns []interface{}
if len(cache.retMapping) != 0 {
returns = queries.PtrsFromMapping(value, cache.retMapping)
}
if boil.IsDebug(ctx) {
writer := boil.DebugWriterFrom(ctx)
fmt.Fprintln(writer, cache.query)
fmt.Fprintln(writer, vals)
}
if len(cache.retMapping) != 0 {
err = exec.QueryRowContext(ctx, cache.query, vals...).Scan(returns...)
if errors.Is(err, sql.ErrNoRows) {
err = nil // Postgres doesn't return anything when there's no update
}
} else {
_, err = exec.ExecContext(ctx, cache.query, vals...)
}
if err != nil {
return errors.Wrap(err, "model: unable to upsert transaction_importer")
}
if !cached {
transactionImporterUpsertCacheMut.Lock()
transactionImporterUpsertCache[key] = cache
transactionImporterUpsertCacheMut.Unlock()
}
return nil
}
// Delete deletes a single TransactionImporter record with an executor.
// Delete will match against the primary key column to find the record to delete.
func (o *TransactionImporter) Delete(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if o == nil {
return 0, errors.New("model: no TransactionImporter provided for delete")
}
args := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(o)), transactionImporterPrimaryKeyMapping)
sql := "DELETE FROM \"transaction_importer\" 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, "model: unable to delete from transaction_importer")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: failed to get rows affected by delete for transaction_importer")
}
return rowsAff, nil
}
// DeleteAll deletes all matching rows.
func (q transactionImporterQuery) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if q.Query == nil {
return 0, errors.New("model: no transactionImporterQuery provided for delete all")
}
queries.SetDelete(q.Query)
result, err := q.Query.ExecContext(ctx, exec)
if err != nil {
return 0, errors.Wrap(err, "model: unable to delete all from transaction_importer")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: failed to get rows affected by deleteall for transaction_importer")
}
return rowsAff, nil
}
// DeleteAll deletes all rows in the slice, using an executor.
func (o TransactionImporterSlice) DeleteAll(ctx context.Context, exec boil.ContextExecutor) (int64, error) {
if len(o) == 0 {
return 0, nil
}
var args []interface{}
for _, obj := range o {
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), transactionImporterPrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := "DELETE FROM \"transaction_importer\" WHERE " +
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, transactionImporterPrimaryKeyColumns, 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, "model: unable to delete all from transactionImporter slice")
}
rowsAff, err := result.RowsAffected()
if err != nil {
return 0, errors.Wrap(err, "model: failed to get rows affected by deleteall for transaction_importer")
}
return rowsAff, nil
}
// Reload refetches the object from the database
// using the primary keys with an executor.
func (o *TransactionImporter) Reload(ctx context.Context, exec boil.ContextExecutor) error {
ret, err := FindTransactionImporter(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 *TransactionImporterSlice) ReloadAll(ctx context.Context, exec boil.ContextExecutor) error {
if o == nil || len(*o) == 0 {
return nil
}
slice := TransactionImporterSlice{}
var args []interface{}
for _, obj := range *o {
pkeyArgs := queries.ValuesFromMapping(reflect.Indirect(reflect.ValueOf(obj)), transactionImporterPrimaryKeyMapping)
args = append(args, pkeyArgs...)
}
sql := "SELECT \"transaction_importer\".* FROM \"transaction_importer\" WHERE " +
strmangle.WhereClauseRepeated(string(dialect.LQ), string(dialect.RQ), 0, transactionImporterPrimaryKeyColumns, len(*o))
q := queries.Raw(sql, args...)
err := q.Bind(ctx, exec, &slice)
if err != nil {
return errors.Wrap(err, "model: unable to reload all in TransactionImporterSlice")
}
*o = slice
return nil
}
// TransactionImporterExists checks if the TransactionImporter row exists.
func TransactionImporterExists(ctx context.Context, exec boil.ContextExecutor, iD int64) (bool, error) {
var exists bool
sql := "select exists(select 1 from \"transaction_importer\" 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, "model: unable to check if transaction_importer exists")
}
return exists, nil
}
// Exists checks if the TransactionImporter row exists.
func (o *TransactionImporter) Exists(ctx context.Context, exec boil.ContextExecutor) (bool, error) {
return TransactionImporterExists(ctx, exec, o.ID)
}