db

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStore

func NewStore(opts ...Option) func(gas.DatabaseProvider, gas.Logger, gas.MigrationManager) *Store

NewStore returns a DI-injectable constructor for Store.

Types

type Option

type Option func(*Store)

Option configures a Store.

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace sets the namespace for this store instance. Defaults to "default" if not specified.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a database-backed template store implementing gas.TemplateProvider. It delegates to sqlc-generated queries, scoped to a namespace so multiple Store instances can share a single table.

func (*Store) Close

func (s *Store) Close() error

Close implements gas.Service.

func (*Store) Delete

func (s *Store) Delete(name string) error

Delete removes a template by name. Returns template.ErrTemplateNotFound if the template does not exist.

func (*Store) Exists

func (s *Store) Exists(name string) (bool, error)

Exists checks whether a template with the given name exists.

func (*Store) Get

func (s *Store) Get(ctx context.Context, name string) ([]byte, error)

Get returns the raw template content by name.

func (*Store) Init

func (s *Store) Init() error

Init implements gas.Service. It registers the templates table migration and selects the correct sqlc adapter based on the configured database driver.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]string, error)

List returns all available template names in sorted order.

func (*Store) Name

func (s *Store) Name() string

Name implements gas.Service.

func (*Store) Register

func (s *Store) Register(ctx context.Context, name string, content []byte) error

Register adds or replaces a template by name.

func (*Store) RegisterFS

func (s *Store) RegisterFS(ctx context.Context, fsys fs.FS) error

RegisterFS walks an fs.FS and upserts every .html file found.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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