Documentation
¶
Overview ¶
Package hummer provides a lightweight service layer built on Bun and integrates the repository and database packages for common data access.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service[T any] interface { // Get returns a single entity by its identifier. Get(ctx context.Context, id any) (*T, error) // All returns all entities. All(ctx context.Context) ([]*T, error) // List returns entities that match the provided filter. List(ctx context.Context, filter *types.Condition) ([]*T, error) // Query executes a raw query and maps the results to entities. Query(ctx context.Context, query string, args ...interface{}) ([]*T, error) // Page returns a paginated list of entities. Page(ctx context.Context, page *types.PageRequest) (*types.Pagination[T], error) // Update modifies an existing entity. Update(ctx context.Context, model ...*T) error // Delete removes an entity by its identifier. Delete(ctx context.Context, id ...any) error // Save inserts one or more new entities. Save(ctx context.Context, model ...*T) error // SaveOrUpdate upserts entities based on fields and duplicate keys. SaveOrUpdate(ctx context.Context, fields []string, duplicateKeys []string, model ...*T) error // SaveWithTx inserts entities within an existing transaction. SaveWithTx(ctx context.Context, tx *bun.Tx, model ...*T) error // SaveOrUpdateWithTx upserts entities within a transaction. SaveOrUpdateWithTx(ctx context.Context, tx *bun.Tx, fields []string, duplicateKeys []string, model ...*T) error // UpdateWithTx updates an entity within a transaction. UpdateWithTx(ctx context.Context, tx *bun.Tx, model ...*T) error // DeleteWithTx removes an entity within a transaction. DeleteWithTx(ctx context.Context, tx *bun.Tx, id ...any) error // SelectBuilder returns a Bun select query builder for the entity. SelectBuilder() *bun.SelectQuery // InsertBuilder returns a Bun insert query builder for the entity. InsertBuilder() *bun.InsertQuery // UpdateBuilder returns a Bun update query builder for the entity. UpdateBuilder() *bun.UpdateQuery // DeleteBuilder returns a Bun delete query builder for the entity. DeleteBuilder() *bun.DeleteQuery }
func NewService ¶
NewService returns a default Service implementation using the generic repository backed by the global database connection.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package database provides connection management, migrations, foreign key handling, SQL initialization, configuration types, logging, health checks, and related utilities built on top of Bun.
|
Package database provides connection management, migrations, foreign key handling, SQL initialization, configuration types, logging, health checks, and related utilities built on top of Bun. |
|
Package repository provides a generic repository abstraction built on Bun for CRUD operations, querying, pagination, transactions, and upsert support.
|
Package repository provides a generic repository abstraction built on Bun for CRUD operations, querying, pagination, transactions, and upsert support. |
|
Package types contains shared data structures used across the project, including enums, JSON helpers, query filters, and pagination models.
|
Package types contains shared data structures used across the project, including enums, JSON helpers, query filters, and pagination models. |
Click to show internal directories.
Click to hide internal directories.