sql: Refactor use of tables

This commit is contained in:
Tom Wiesing 2023-01-09 10:24:24 +01:00
parent 85fe5b5c5a
commit 73d821e320
No known key found for this signature in database
19 changed files with 191 additions and 83 deletions

View file

@ -22,6 +22,8 @@ type Instances struct {
Dependencies struct {
Malt *malt.Malt
SQL *sql.SQL
InstanceTable *sql.InstanceTable
}
}
@ -50,7 +52,7 @@ func (instances *Instances) WissKI(ctx context.Context, slug string) (wissKI *wi
return nil, err
}
table, err := sql.QueryTable(ctx, false, models.InstanceTable)
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
if err != nil {
return nil, err
}
@ -90,7 +92,7 @@ func (instances *Instances) Has(ctx context.Context, slug string) (ok bool, err
return false, err
}
table, err := sql.QueryTable(ctx, false, models.InstanceTable)
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
if err != nil {
return false, err
}
@ -135,7 +137,7 @@ func (instances *Instances) find(ctx context.Context, order bool, query func(tab
}
// open the bookkeeping table
table, err := sql.QueryTable(ctx, false, models.InstanceTable)
table, err := sql.QueryTable(ctx, instances.Dependencies.InstanceTable)
if err != nil {
return nil, err
}

View file

@ -13,8 +13,11 @@ import (
type Malt struct {
component.Base
SQL *sql.SQL `auto:"true"`
InstanceTable *sql.InstanceTable `auto:"true"`
LockTable *sql.LockTable `auto:"true"`
TS *triplestore.Triplestore `auto:"true"`
SQL *sql.SQL `auto:"true"`
Meta *meta.Meta `auto:"true"`
ExporterLog *logger.Logger `auto:"true"`
Policy *policy.Policy `auto:"true"`