examples

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorUser

type ErrorUser User

ErrorUser is a type that deliberately returns a non-existent table name to force an error during retrieval.

func (*ErrorUser) InsertedValues

func (eu *ErrorUser) InsertedValues() ([]string, []any)

InsertedValues returns the column names and values for insertion.

Returns:

  • []string: The column names.
  • []any: The values.

func (*ErrorUser) ScanRow

func (eu *ErrorUser) ScanRow(row database.Row) error

ScanRow populates the ErrorUser from a DB row.

Parameters:

  • row: The DB row to scan.

Returns:

  • error: An error if the scan fails.

func (*ErrorUser) TableName

func (eu *ErrorUser) TableName() string

TableName returns a table name that does not exist.

Returns:

  • string: The table name.

type SimpleErrorChecker

type SimpleErrorChecker struct{}

SimpleErrorChecker is a trivial custom error checker that returns a custom translated error from the original error.

func (*SimpleErrorChecker) Check

func (ec *SimpleErrorChecker) Check(err error) error

Check returns the error without modification.

Parameters:

  • err: The error to check.

Returns:

  • error: The translated error.

type SimpleQuery

type SimpleQuery struct{}

SimpleQuery implements the DataMutatorQuery and DataReaderQuery interfaces.

func (*SimpleQuery) Count

func (q *SimpleQuery) Count(
	table string, opts *db.CountOptions,
) (string, []any)

func (*SimpleQuery) Delete

func (q *SimpleQuery) Delete(
	table string, selectors []db.Selector, opts *db.DeleteOptions,
) (string, []any)

func (*SimpleQuery) Get

func (q *SimpleQuery) Get(
	table string, opts *db.GetOptions,
) (string, []any)

Get builds a simple SELECT query for the given table.

Parameters:

  • table: The table to query.
  • opts: Optional GetOptions.

Returns:

  • string: The query.
  • []any: The values.

func (*SimpleQuery) Insert

func (q *SimpleQuery) Insert(
	table string, insertedValuesFn db.InsertedValuesFn,
) (string, []any)

Insert builds an INSERT query based on the provided inserted values.

Parameters:

  • table: The table to insert into.
  • insertedValuesFn: A function that returns the column names and values.

Returns:

  • string: The query.
  • []any: The values.

func (*SimpleQuery) InsertMany

func (q *SimpleQuery) InsertMany(
	table string, valuesFuncs []db.InsertedValuesFn,
) (query string, params []any)

func (*SimpleQuery) UpdateQuery

func (q *SimpleQuery) UpdateQuery(
	table string, updates []db.Update, selectors []db.Selector,
) (string, []any)

func (*SimpleQuery) UpsertMany

func (q *SimpleQuery) UpsertMany(
	table string, valuesFuncs []db.InsertedValuesFn,
	updateProjections []db.Projection,
) (string, []any)

type SimpleSchemaManager

type SimpleSchemaManager struct{}

SimpleSchemaManager implements the SchemaManager interface for demonstration.

func (*SimpleSchemaManager) CreateDatabaseQuery

func (sm *SimpleSchemaManager) CreateDatabaseQuery(
	dbName string, ifNotExists bool, charset string, collate string,
) (string, []any, error)

func (*SimpleSchemaManager) CreateTableQuery

func (sm *SimpleSchemaManager) CreateTableQuery(
	tableName string,
	ifNotExists bool,
	columns []db.ColumnDefinition,
	constraints []string,
	opts db.TableOptions,
) (string, []any, error)

CreateTableQuery builds a CREATE TABLE statement.

Parameters:

  • tableName: The name of the table to create.
  • ifNotExists: Whether to create the table if it doesn't exist.
  • columns: The column definitions for the table.
  • constraints: Additional constraints for the table.
  • opts: Optional table options.

Returns:

  • string: The query.
  • []any: The values.

func (*SimpleSchemaManager) SetVariableQuery

func (sm *SimpleSchemaManager) SetVariableQuery(
	variable string, value string,
) (string, []any, error)

func (*SimpleSchemaManager) UseDatabaseQuery

func (sm *SimpleSchemaManager) UseDatabaseQuery(
	dbName string,
) (string, []any, error)

type User

type User struct {
	ID   int64
	Name string
}

User represents a simple entity for demonstration. It implements both Getter and Mutator interfaces.

func (*User) InsertedValues

func (u *User) InsertedValues() ([]string, []any)

InsertedValues returns the column names and values for insertion.

Returns:

  • []string: The column names.
  • []any: The values.

func (*User) ScanRow

func (u *User) ScanRow(row database.Row) error

ScanRow populates the User from a DB row.

Parameters:

  • row: The DB row to scan.

Returns:

  • error: An error if the scan fails.

func (*User) TableName

func (u *User) TableName() string

TableName returns the DB table name for User.

Returns:

  • string: The table name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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