Skip to content

Commit

Permalink
feat: support create from existing connection pool
Browse files Browse the repository at this point in the history
  • Loading branch information
fredliang44 authored Dec 10, 2024
1 parent 2051f80 commit 79a8c60
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ type Dialector struct {
Conn gorm.ConnPool
}

type Config struct {
DriverName string
DSN string
Conn gorm.ConnPool
}


func Open(dsn string) gorm.Dialector {
return &Dialector{DSN: dsn}
}
Expand Down Expand Up @@ -73,6 +80,10 @@ func (dialector Dialector) Initialize(db *gorm.DB) (err error) {
return
}

func New(config Config) gorm.Dialector {
return &Dialector{DSN: config.DSN, DriverName: config.DriverName, Conn: config.Conn}
}

func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder {
return map[string]clause.ClauseBuilder{
"INSERT": func(c clause.Clause, builder clause.Builder) {
Expand Down

0 comments on commit 79a8c60

Please sign in to comment.