postgresgorm

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bundle

func Bundle() sen.Plugin

Bundle is a sen.Plugin that provides both Config and gorm.DB for convenience.

Usage

app.With(postgresgorm.Bundle())

Types

type Config

type Config struct {
	DSN string `env:"POSTGRESQL_DSN,required"`
}

Config includes configuration to initialize a gorm.DB to a PostgreSQL server.

type Plugin

type Plugin struct {
	Hub    sen.Hub `inject:"hub"`
	Config *Config `inject:"postgresgorm.config"`
}

Plugin is a plugin that provides an instance of gorm.DB. Check gorm.io to see how to use gorm to work with databases. The plugin requires Config is registered in advance.

Usage

app.With(&postgresgorm.Plugin{})

func (*Plugin) Initialize

func (p *Plugin) Initialize() error

Initialize creates a new instance of *gorm.DB with the given configuration. And then registers it into the application as `gorm`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL