项目文件夹

文件

项目文件夹

0
T

31 行
578 B
Go

package model
// Options holds configuration for a Model.
type Options struct {
2026-03-04 13:13:34 +00:00
// DSN is the data source name / connection string.
DSN string
}
// WithDSN sets the data source name.
2026-03-04 13:13:34 +00:00
func WithDSN(dsn string) Option {
return func(o *Options) {
2026-03-04 13:13:34 +00:00
o.DSN = dsn
}
}
// NewOptions creates Options with defaults applied.
func NewOptions(opts ...Option) Options {
o := Options{}
2026-03-04 13:13:34 +00:00
for _, opt := range opts {
opt(&o)
}
2026-03-04 13:13:34 +00:00
return o
}
2026-03-04 13:13:34 +00:00
// WithTable overrides the auto-derived table name.
func WithTable(name string) RegisterOption {
2026-03-04 13:13:34 +00:00
return func(s *Schema) {
s.Table = name
}
}