database

package
v0.0.0-...-b0bf924 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package database provides the database access functions and schema.

Index

Constants

This section is empty.

Variables

View Source
var SchemaExtensions = []schema.Update{
	schemaAppend1,
	schemaAppend2,
}

SchemaExtensions is a list of schema extensions that can be passed to the MicroCluster daemon. Each entry will increase the database schema version by one, and will be applied after internal schema updates.

Functions

func CreateExtendedTable

func CreateExtendedTable(ctx context.Context, tx *sql.Tx, object ExtendedTable) (int64, error)

CreateExtendedTable adds a new extended_table to the database. generator: extended_table Create

func DeleteExtendedTable

func DeleteExtendedTable(ctx context.Context, tx *sql.Tx, key string) error

DeleteExtendedTable deletes the extended_table matching the given key parameters. generator: extended_table DeleteOne-by-Key

func ExtendedTableExists

func ExtendedTableExists(ctx context.Context, tx *sql.Tx, key string) (bool, error)

ExtendedTableExists checks if a extended_table with the given key exists. generator: extended_table Exists

func GetExtendedTableID

func GetExtendedTableID(ctx context.Context, tx *sql.Tx, key string) (int64, error)

GetExtendedTableID return the ID of the extended_table with the given key. generator: extended_table ID

func UpdateExtendedTable

func UpdateExtendedTable(ctx context.Context, tx *sql.Tx, key string, object ExtendedTable) error

UpdateExtendedTable updates the extended_table matching the given key parameters. generator: extended_table Update

Types

type ExtendedTable

type ExtendedTable struct {
	ID    int
	Key   string `db:"primary=yes"`
	Value string
}

ExtendedTable is an example of a database table. In this case named `extended_table`. The above comments will generate database queries and helpers using lxd-generate.

func GetExtendedTable

func GetExtendedTable(ctx context.Context, tx *sql.Tx, key string) (*ExtendedTable, error)

GetExtendedTable returns the extended_table with the given key. generator: extended_table GetOne

func GetExtendedTables

func GetExtendedTables(ctx context.Context, tx *sql.Tx, filters ...ExtendedTableFilter) ([]ExtendedTable, error)

GetExtendedTables returns all available extended_tables. generator: extended_table GetMany

type ExtendedTableFilter

type ExtendedTableFilter struct {
	Key *string
}

ExtendedTableFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches. In this case we will only support filtering by Key.

Jump to

Keyboard shortcuts

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