data

package
v0.0.0-...-d72fd11 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package data provides a set of data types for the database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Schema is the schema for the libsql database
	Schema string
	// URI is the uri for the libsql database
	URI string
	// Name is the name for the libsql database
	Name string
	// FileName is the file name for the sqlite database
	FileName string
}

Config is a struct that holds the configuration for a database.

type Database

type Database[
	T master.Queries,
] struct {
	Queries *T
	Bun     *bun.DB
}

Database is a struct that holds the sql database and the queries. It uses generics to hold the appropriate type of query struct.

func NewDb

func NewDb[
	Q master.Queries,
](
	ctx context.Context,
	newFunc func(generic.DBTX) *Q,
	config *Config,
) (*Database[Q], error)

NewDb sets up the database using the URI and optional options. Using generics to return the appropriate type of query struct, it creates a new database struct with the sql database and the queries struct utilizing the URI and optional options provided.

func NewSQLDatabase

func NewSQLDatabase[
	Q master.Queries,
](
	parentCtx context.Context,
	dialect schema.Dialect,
	db *sql.DB,
	newFunc func(generic.DBTX) *Q,
) (*Database[Q], error)

NewSQLDatabase creates a new database struct with the sql database and the queries struct. It uses generics to return the appropriate type of query

type SetupFunc

type SetupFunc func(ctx context.Context, getenv func(string) string, db *bun.DB) error

SetupFunc is a function for setting up the database

Directories

Path Synopsis
Package generic provides a generic interface for a database.
Package generic provides a generic interface for a database.
Package master contains the sqlite database schema
Package master contains the sqlite database schema

Jump to

Keyboard shortcuts

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