Database type now accepts a context for its first argument when created
with NewDatabase.
This commit is contained in:
parent
5ed34450d6
commit
ccb838714a
1 changed files with 12 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"code.destrealm.net/zancarius/justusbot/internal/settings"
|
||||
|
|
@ -15,12 +16,14 @@ var ErrNoRows = errors.NewError("no rows")
|
|||
var ErrUniqueConstraint = errors.NewError("unique constraint failed")
|
||||
|
||||
type Database struct {
|
||||
ctx context.Context
|
||||
db *sqlx.DB
|
||||
conf *settings.Settings
|
||||
}
|
||||
|
||||
func OpenDatabase(conf *settings.Settings) *Database {
|
||||
func OpenDatabase(ctx context.Context, conf *settings.Settings) *Database {
|
||||
return &Database{
|
||||
ctx: ctx,
|
||||
conf: conf,
|
||||
}
|
||||
}
|
||||
|
|
@ -52,3 +55,11 @@ func (d *Database) Migrate(migrations vfs.VFS) error {
|
|||
|
||||
return migrator.Up()
|
||||
}
|
||||
|
||||
func (d *Database) Chats() *ChatModel {
|
||||
return NewChatModel(d.ctx, d.db)
|
||||
}
|
||||
|
||||
func (d *Database) Verses() (*VerseModel, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue