Documentation
¶
Index ¶
- type ErrorUser
- type SimpleErrorChecker
- type SimpleQuery
- func (q *SimpleQuery) Count(table string, opts *db.CountOptions) (string, []any)
- func (q *SimpleQuery) Delete(table string, selectors []db.Selector, opts *db.DeleteOptions) (string, []any)
- func (q *SimpleQuery) Get(table string, opts *db.GetOptions) (string, []any)
- func (q *SimpleQuery) Insert(table string, insertedValuesFn db.InsertedValuesFn) (string, []any)
- func (q *SimpleQuery) InsertMany(table string, valuesFuncs []db.InsertedValuesFn) (query string, params []any)
- func (q *SimpleQuery) UpdateQuery(table string, updates []db.Update, selectors []db.Selector) (string, []any)
- func (q *SimpleQuery) UpsertMany(table string, valuesFuncs []db.InsertedValuesFn, ...) (string, []any)
- type SimpleSchemaManager
- func (sm *SimpleSchemaManager) CreateDatabaseQuery(dbName string, ifNotExists bool, charset string, collate string) (string, []any, error)
- func (sm *SimpleSchemaManager) CreateTableQuery(tableName string, ifNotExists bool, columns []db.ColumnDefinition, ...) (string, []any, error)
- func (sm *SimpleSchemaManager) SetVariableQuery(variable string, value string) (string, []any, error)
- func (sm *SimpleSchemaManager) UseDatabaseQuery(dbName string) (string, []any, error)
- type User
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 ¶
InsertedValues returns the column names and values for insertion.
Returns:
- []string: The column names.
- []any: The values.
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 (*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 (*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 (*SimpleSchemaManager) UseDatabaseQuery ¶
func (sm *SimpleSchemaManager) UseDatabaseQuery( dbName string, ) (string, []any, error)
type User ¶
User represents a simple entity for demonstration. It implements both Getter and Mutator interfaces.
func (*User) InsertedValues ¶
InsertedValues returns the column names and values for insertion.
Returns:
- []string: The column names.
- []any: The values.