Plugins¶
Plugins allow you to package and reuse schema configurations. A plugin is simply a function that takes a *goose.Schema.
Using Plugins¶
You can apply a plugin to a schema using the Use method.
func TimestampPlugin(s *goose.Schema) {
s.Pre("Save", func(ctx context.Context, doc any) error {
// Set CreatedAt and UpdatedAt
return nil
})
}
userSchema.Use(TimestampPlugin)
Community Plugins
Plugins are a great way to share common functionality across multiple schemas or open-source your Goose extensions.