Skip to content

Commit

Permalink
Simplify dbx wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Jun 1, 2024
1 parent 4df69bd commit 8c3919d
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions persistence/dbx_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 8c3919d

Please sign in to comment.