gorm db openned in options

This commit is contained in:
2020-03-03 14:54:53 +01:00
parent 3375b4f379
commit ac9a81d3e7
2 changed files with 14 additions and 2 deletions

View File

@ -144,9 +144,11 @@ func WithKey(path string) Option {
}
}
func WithDB(db *gorm.DB) Option {
func WithDB(dialect string, args ...interface{}) Option {
db, err := gorm.Open(dialect, args...)
return func(o *options) {
o.db = db
o.error = err
}
}
@ -236,6 +238,8 @@ type options struct {
clientInterceptors []grpc.UnaryClientInterceptor
streamClientInterceptors []grpc.StreamClientInterceptor
error error
}
func (o *options) Name() string {