mirror of https://github.com/VinGarcia/ksql.git
Update NewClient to actually work
parent
06a7e37d0e
commit
a3af26e3bd
17
postgres.go
17
postgres.go
|
@ -15,10 +15,21 @@ type Client struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient ...
|
// NewClient ...
|
||||||
func NewClient(tableName string) Client {
|
func NewClient(dbDriver string, connectionString string, maxOpenConns int) (Client, error) {
|
||||||
return Client{
|
db, err := gorm.Open(dbDriver, connectionString)
|
||||||
tableName: tableName,
|
if err != nil {
|
||||||
|
return Client{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = db.DB().Ping(); err != nil {
|
||||||
|
return Client{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
db.DB().SetMaxOpenConns(maxOpenConns)
|
||||||
|
|
||||||
|
return Client{
|
||||||
|
db: db,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find one instance from the database, the input struct
|
// Find one instance from the database, the input struct
|
||||||
|
|
Loading…
Reference in New Issue