data

package
v0.0.0-...-4fcc4bf Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2024 License: MIT Imports: 8 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 ConfigFile

type ConfigFile struct {
	URLs struct {
		URL string `json:"url" yaml:"url"`
	} `json:"urls" yaml:"urls"`
}

ConfigFile is a struct for a config file.

type Database

type Database[
	T master.Queries,
] struct {
	Queries *T
	DB      *sql.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,
	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

Directories

Path Synopsis
Package generic provides a generic interface for a database.
Package generic provides a generic interface for a database.
Package logs contains the sqlite database schema
Package logs contains the sqlite database schema
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