Help us shape the future of Go! Take the 2026 Go Developer Survey

repository

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package repository provides data access layer for quad-ops units.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	FindAll() ([]Unit, error)
	FindByUnitType(unitType string) ([]Unit, error)
	FindByID(id int64) (Unit, error)
	Create(unit *Unit) (int64, error)
	Delete(id int64) error
}

Repository defines the interface for unit data access operations.

func NewRepository

func NewRepository(db *sql.DB) Repository

NewRepository creates a new SQL-based unit repository.

type SQLRepository

type SQLRepository struct {
	// contains filtered or unexported fields
}

SQLRepository implements Repository interface with SQL database.

func (*SQLRepository) Create

func (r *SQLRepository) Create(unit *Unit) (int64, error)

Create inserts or updates a unit in the database.

func (*SQLRepository) Delete

func (r *SQLRepository) Delete(id int64) error

Delete removes a unit from the database.

func (*SQLRepository) FindAll

func (r *SQLRepository) FindAll() ([]Unit, error)

FindAll retrieves all units from the database.

func (*SQLRepository) FindByID

func (r *SQLRepository) FindByID(id int64) (Unit, error)

FindByID retrieves a single unit by ID.

func (*SQLRepository) FindByUnitType

func (r *SQLRepository) FindByUnitType(unitType string) ([]Unit, error)

FindByUnitType retrieves units filtered by type.

type Unit

type Unit struct {
	ID            int64     `db:"id"`
	Name          string    `db:"name"`
	Type          string    `db:"type"`
	CleanupPolicy string    `db:"cleanup_policy"`
	SHA1Hash      []byte    `db:"sha1_hash"`
	UserMode      bool      `db:"user_mode"`
	CreatedAt     time.Time `db:"created_at"` // Set by database, but not updated on every change
}

Unit represents a record in the units table.

Jump to

Keyboard shortcuts

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