Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPageSize = domain.ErrInvalidPageSize
Functions ¶
This section is empty.
Types ¶
type NewPageOpt ¶ added in v0.8.0
type NewPageOpt[T any] = domain.NewPageOpt[T]
func WithNewPageContent ¶ added in v0.8.0
func WithNewPageContent[T any](dest *[]T) NewPageOpt[T]
WithNewPageContent sets page's the desitination slice. If set, ContentInitSize will be ignored
func WithNewPageContentInitSize ¶ added in v0.8.0
WithNewPageContentInitSize sets page's the desitination init size.
type Page ¶ added in v0.8.0
func NewEmptyPage ¶ added in v0.8.0
func NewEmptyPage[T any]() Page[T]
NewEmptyPage creates a page with no content and zero counters.
type PageOpt ¶ added in v0.8.0
func WithPageNumber ¶ added in v0.8.0
func WithPageNumber(number uint) PageOpt
WithPageNumber sets the page number. The page number is 0-based, meaning the first page is 0.
func WithPageSize ¶ added in v0.8.0
func WithPageSize(size uint) PageOpt
WithPageSize sets the number of items per page. The page size must be greater than 0.
func WithSortBy ¶ added in v0.8.0
func WithSortBy(column string) PageOpt
WithSortBy adds a column to sort by. Multiple calls will append to the list of sort columns. If no sort columns are specified, the default is to sort by ID.
func WithSortDesc ¶ added in v0.8.0
func WithSortDesc(column string) PageOpt
WithSortDesc sets the sort order to descending. By default, the sort order is ascending.
type PageResolver ¶ added in v0.8.0
type PageResolver[T any] = domain.PageResolver[T]
type SQLCredo ¶
type SQLCredo[T any, I comparable] interface { SQLExecutor CRUD[T, I] PageResolver[T] TransactionExecutor[T, I] // InitSchema executes a SQL query to initialize the database schema. // Typically used for creating tables and other database objects. InitSchema(ctx context.Context, sql string) (sql.Result, error) // WithDebugFunc sets a debug function for SQL query logging. // The debug function will be called before executing any SQL query. // Returns the modified SQLCredo instance for method chaining. WithDebugFunc(newDebugFunc DebugFunc) SQLCredo[T, I] // GetDebugFunc returns the currently set debug function. // Returns nil if no debug function is set. GetDebugFunc() DebugFunc }
SQLCredo is a comprehensive interface that combines SQL execution, CRUD operations, and pagination capabilities for a specific entity type.
Type Parameters:
- T: The entity type being managed (can be any type)
- I: The type of the entity's ID field (must be comparable)
func NewSQLCredo ¶
func NewSQLCredo[T any, I comparable](db *sql.DB, driver string, tableName string, idColumn string) SQLCredo[T, I]
NewSQLCredo creates a new instance of SQLCredo for the specified entity type and ID type.
Parameters:
- db: A pointer to the underlying database connection
- driver: The database driver name (e.g., "postgres", "mysql")
- tableName: The name of the database table for the entity
- idColumn: The name of the ID column in the table
Returns a fully initialized SQLCredo instance
type SQLExecutor ¶ added in v0.8.0
type SQLExecutor = domain.SQLExecutor
type Transaction ¶ added in v0.8.0
type Transaction[T any, I comparable] = domain.Transaction[T, I]
type TransactionExecutor ¶ added in v0.8.0
type TransactionExecutor[T any, I comparable] = domain.TransactionExecutor[T, I]