mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-03 20:47:35 +03:00
Simplify dbx wrapper
This commit is contained in:
parent
4df69bd334
commit
8c3919d6a0
1 changed files with 4 additions and 32 deletions
|
@ -7,44 +7,16 @@ import (
|
|||
|
||||
type dbxBuilder struct {
|
||||
dbx.Builder
|
||||
rdb dbx.Builder
|
||||
wdb dbx.Builder
|
||||
}
|
||||
|
||||
func NewDBXBuilder(d db.DB) *dbxBuilder {
|
||||
b := &dbxBuilder{}
|
||||
b.Builder = dbx.NewFromDB(d.WriteDB(), db.Driver)
|
||||
b.rdb = dbx.NewFromDB(d.ReadDB(), db.Driver)
|
||||
b.Builder = dbx.NewFromDB(d.ReadDB(), db.Driver)
|
||||
b.wdb = dbx.NewFromDB(d.WriteDB(), db.Driver)
|
||||
return b
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) NewQuery(s string) *dbx.Query {
|
||||
return d.rdb.NewQuery(s)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) Select(s ...string) *dbx.SelectQuery {
|
||||
return d.rdb.Select(s...)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) GeneratePlaceholder(i int) string {
|
||||
return d.rdb.GeneratePlaceholder(i)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) Quote(s string) string {
|
||||
return d.rdb.Quote(s)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) QuoteSimpleTableName(s string) string {
|
||||
return d.rdb.QuoteSimpleTableName(s)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) QuoteSimpleColumnName(s string) string {
|
||||
return d.rdb.QuoteSimpleColumnName(s)
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) QueryBuilder() dbx.QueryBuilder {
|
||||
return d.rdb.QueryBuilder()
|
||||
}
|
||||
|
||||
func (d *dbxBuilder) Transactional(f func(*dbx.Tx) error) (err error) {
|
||||
return d.Builder.(*dbx.DB).Transactional(f)
|
||||
return d.wdb.(*dbx.DB).Transactional(f)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue