models

package
v0.0.0-...-c14c6da Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package models contains generated code for schema 'loop.db'.

Index

Constants

This section is empty.

Variables

View Source
var TimestampFormats = []string{

	"2006-01-02 15:04:05.999999999-07:00",
	"2006-01-02T15:04:05.999999999-07:00",
	"2006-01-02 15:04:05.999999999",
	"2006-01-02T15:04:05.999999999",
	"2006-01-02 15:04:05",
	"2006-01-02T15:04:05",
	"2006-01-02 15:04",
	"2006-01-02T15:04",
	"2006-01-02",
}

TimestampFormats are the timestamp formats used by SQLite3 database drivers to store a time.Time in SQLite3.

The first format in the slice will be used when saving time values into the database. When parsing a string from a timestamp or datetime column, the formats are tried in order.

Functions

func Errorf

func Errorf(s string, v ...interface{})

Errorf logs an error message using the package error logger.

func Logf

func Logf(s string, v ...interface{})

Logf logs a message using the package logger.

func SetErrorLogger

func SetErrorLogger(logger interface{})

SetErrorLogger sets the package error logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

func SetLogger

func SetLogger(logger interface{})

SetLogger sets the package logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

Types

type Conn

type Conn = sql.DB

func Open

func Open(config *cfg.Config) (*Conn, error)

type DB

type DB interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

DB is the common interface for database operations that can be used with types from schema 'loop.db'.

This works with both database/sql.DB and database/sql.Tx.

type ErrInsertFailed

type ErrInsertFailed struct {
	Err error
}

ErrInsertFailed is the insert failed error.

func (*ErrInsertFailed) Error

func (err *ErrInsertFailed) Error() string

Error satisfies the error interface.

func (*ErrInsertFailed) Unwrap

func (err *ErrInsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrInvalidTime

type ErrInvalidTime string

ErrInvalidTime is the invalid Time error.

func (ErrInvalidTime) Error

func (err ErrInvalidTime) Error() string

Error satisfies the error interface.

type ErrUpdateFailed

type ErrUpdateFailed struct {
	Err error
}

ErrUpdateFailed is the update failed error.

func (*ErrUpdateFailed) Error

func (err *ErrUpdateFailed) Error() string

Error satisfies the error interface.

func (*ErrUpdateFailed) Unwrap

func (err *ErrUpdateFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrUpsertFailed

type ErrUpsertFailed struct {
	Err error
}

ErrUpsertFailed is the upsert failed error.

func (*ErrUpsertFailed) Error

func (err *ErrUpsertFailed) Error() string

Error satisfies the error interface.

func (*ErrUpsertFailed) Unwrap

func (err *ErrUpsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type Error

type Error string

Error is an error.

const (
	// ErrAlreadyExists is the already exists error.
	ErrAlreadyExists Error = "already exists"
	// ErrDoesNotExist is the does not exist error.
	ErrDoesNotExist Error = "does not exist"
	// ErrMarkedForDeletion is the marked for deletion error.
	ErrMarkedForDeletion Error = "marked for deletion"
)

Error values.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type FindRunResult

type FindRunResult struct {
	ID string `json:"id"` // id
}

FindRunResult represents a row from 'find_run_result'.

func FindRunResultsByPathValue

func FindRunResultsByPathValue(ctx context.Context, db DB, path string, value any) ([]*FindRunResult, error)

FindRunResultsByPathValue runs a custom query, returning results as FindRunResult.

type IndexRunsResult

type IndexRunsResult struct {
	ID string `json:"id"` // id
}

IndexRunsResult represents a row from 'index_runs_result'.

func GetIndexRunsResults

func GetIndexRunsResults(ctx context.Context, db DB) ([]*IndexRunsResult, error)

GetIndexRunsResults runs a custom query, returning results as IndexRunsResult.

type Meta

type Meta map[string]any

func (Meta) Omit

func (m Meta) Omit()

type Run

type Run struct {
	ID          string         `json:"id"`           // id
	UserID      string         `json:"user_id"`      // user_id
	ThunkDigest string         `json:"thunk_digest"` // thunk_digest
	StartTime   Time           `json:"start_time"`   // start_time
	EndTime     *Time          `json:"end_time"`     // end_time
	Succeeded   sql.NullInt64  `json:"succeeded"`    // succeeded
	Meta        sql.NullString `json:"meta"`         // meta
	// contains filtered or unexported fields
}

Run represents a row from 'runs'.

func CreateThunkRun

func CreateThunkRun(ctx context.Context, db DB, user *github.User, thunk bass.Thunk, meta map[string]any) (*Run, error)

func RunByID

func RunByID(ctx context.Context, db DB, id string) (*Run, error)

RunByID retrieves a row from 'runs' as a Run.

Generated from index 'sqlite_autoindex_runs_1'.

func RunsByThunkDigest

func RunsByThunkDigest(ctx context.Context, db DB, thunkDigest string) ([]*Run, error)

RunsByThunkDigest retrieves a row from 'runs' as a Run.

Generated from index 'idx_thunk_runs_digest'.

func RunsByUserID

func RunsByUserID(ctx context.Context, db DB, userID string) ([]*Run, error)

RunsByUserID retrieves a row from 'runs' as a Run.

Generated from index 'idx_thunk_runs_user_id'.

func (*Run) Delete

func (r *Run) Delete(ctx context.Context, db DB) error

Delete deletes the Run from the database.

func (*Run) Deleted

func (r *Run) Deleted() bool

Deleted returns true when the Run has been marked for deletion from the database.

func (*Run) Exists

func (r *Run) Exists() bool

Exists returns true when the Run exists in the database.

func (*Run) Insert

func (r *Run) Insert(ctx context.Context, db DB) error

Insert inserts the Run to the database.

func (*Run) Save

func (r *Run) Save(ctx context.Context, db DB) error

Save saves the Run to the database.

func (*Run) Thunk

func (r *Run) Thunk(ctx context.Context, db DB) (*Thunk, error)

Thunk returns the Thunk associated with the Run's (ThunkDigest).

Generated from foreign key 'runs_thunk_digest_fkey'.

func (*Run) Update

func (r *Run) Update(ctx context.Context, db DB) error

Update updates a Run in the database.

func (*Run) Upsert

func (r *Run) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Run.

func (*Run) User

func (r *Run) User(ctx context.Context, db DB) (*User, error)

User returns the User associated with the Run's (UserID).

Generated from foreign key 'runs_user_id_fkey'.

type Runtime

type Runtime struct {
	UserID    string `json:"user_id"`    // user_id
	Name      string `json:"name"`       // name
	Os        string `json:"os"`         // os
	Arch      string `json:"arch"`       // arch
	ExpiresAt Time   `json:"expires_at"` // expires_at
	Priority  int    `json:"priority"`   // priority
	// contains filtered or unexported fields
}

Runtime represents a row from 'runtimes'.

func RuntimeByUserIDName

func RuntimeByUserIDName(ctx context.Context, db DB, userID, name string) (*Runtime, error)

RuntimeByUserIDName retrieves a row from 'runtimes' as a Runtime.

Generated from index 'sqlite_autoindex_runtimes_1'.

func RuntimesByUserID

func RuntimesByUserID(ctx context.Context, db DB, userID string) ([]*Runtime, error)

RuntimesByUserID retrieves a row from 'runtimes' as a Runtime.

Generated from index 'idx_runtimes_user_id'.

func (*Runtime) Delete

func (r *Runtime) Delete(ctx context.Context, db DB) error

Delete deletes the Runtime from the database.

func (*Runtime) Deleted

func (r *Runtime) Deleted() bool

Deleted returns true when the Runtime has been marked for deletion from the database.

func (*Runtime) Exists

func (r *Runtime) Exists() bool

Exists returns true when the Runtime exists in the database.

func (*Runtime) Insert

func (r *Runtime) Insert(ctx context.Context, db DB) error

Insert inserts the Runtime to the database.

func (*Runtime) Save

func (r *Runtime) Save(ctx context.Context, db DB) error

Save saves the Runtime to the database.

func (*Runtime) Update

func (r *Runtime) Update(ctx context.Context, db DB) error

Update updates a Runtime in the database.

func (*Runtime) Upsert

func (r *Runtime) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Runtime.

func (*Runtime) User

func (r *Runtime) User(ctx context.Context, db DB) (*User, error)

User returns the User associated with the Runtime's (UserID).

Generated from foreign key 'runtimes_user_id_fkey'.

type SchemaMigration

type SchemaMigration struct {
	Version sql.NullString `json:"version"` // version
	Dirty   sql.NullBool   `json:"dirty"`   // dirty
}

SchemaMigration represents a row from 'schema_migrations'.

func SchemaMigrationByVersion

func SchemaMigrationByVersion(ctx context.Context, db DB, version sql.NullString) (*SchemaMigration, error)

SchemaMigrationByVersion retrieves a row from 'schema_migrations' as a SchemaMigration.

Generated from index 'version_unique'.

type Service

type Service struct {
	UserID      string `json:"user_id"`      // user_id
	RuntimeName string `json:"runtime_name"` // runtime_name
	Service     string `json:"service"`      // service
	Addr        string `json:"addr"`         // addr
	// contains filtered or unexported fields
}

Service represents a row from 'services'.

func ServiceByRuntimeNameService

func ServiceByRuntimeNameService(ctx context.Context, db DB, runtimeName, service string) (*Service, error)

ServiceByRuntimeNameService retrieves a row from 'services' as a Service.

Generated from index 'sqlite_autoindex_services_1'.

func ServiceByUserIDRuntimeNameService

func ServiceByUserIDRuntimeNameService(ctx context.Context, db DB, userID, runtimeName, service string) (*Service, error)

ServiceByUserIDRuntimeNameService retrieves a row from 'services' as a Service.

Generated from index 'service_user_runtime_service_idx'.

func ServicesByUserIDRuntimeName

func ServicesByUserIDRuntimeName(ctx context.Context, db DB, userID, runtimeName string) ([]*Service, error)

ServicesByUserIDRuntimeName retrieves a row from 'services' as a Service.

Generated from index 'idx_services_runtime_name'.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, db DB) error

Delete deletes the Service from the database.

func (*Service) Deleted

func (s *Service) Deleted() bool

Deleted returns true when the Service has been marked for deletion from the database.

func (*Service) Exists

func (s *Service) Exists() bool

Exists returns true when the Service exists in the database.

func (*Service) Insert

func (s *Service) Insert(ctx context.Context, db DB) error

Insert inserts the Service to the database.

func (*Service) Save

func (s *Service) Save(ctx context.Context, db DB) error

Save saves the Service to the database.

func (*Service) Update

func (s *Service) Update(ctx context.Context, db DB) error

Update updates a Service in the database.

func (*Service) Upsert

func (s *Service) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Service.

func (*Service) User

func (s *Service) User(ctx context.Context, db DB) (*User, error)

User returns the User associated with the Service's (UserID).

Generated from foreign key 'services_user_id_fkey'.

type Thunk

type Thunk struct {
	Digest string `json:"digest"` // digest
	JSON   []byte `json:"json"`   // json
	// contains filtered or unexported fields
}

Thunk represents a row from 'thunks'.

func ThunkByDigest

func ThunkByDigest(ctx context.Context, db DB, digest string) (*Thunk, error)

ThunkByDigest retrieves a row from 'thunks' as a Thunk.

Generated from index 'sqlite_autoindex_thunks_1'.

func (*Thunk) Delete

func (t *Thunk) Delete(ctx context.Context, db DB) error

Delete deletes the Thunk from the database.

func (*Thunk) Deleted

func (t *Thunk) Deleted() bool

Deleted returns true when the Thunk has been marked for deletion from the database.

func (*Thunk) Exists

func (t *Thunk) Exists() bool

Exists returns true when the Thunk exists in the database.

func (*Thunk) Insert

func (t *Thunk) Insert(ctx context.Context, db DB) error

Insert inserts the Thunk to the database.

func (*Thunk) Save

func (t *Thunk) Save(ctx context.Context, db DB) error

Save saves the Thunk to the database.

func (*Thunk) Update

func (t *Thunk) Update(ctx context.Context, db DB) error

Update updates a Thunk in the database.

func (*Thunk) Upsert

func (t *Thunk) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Thunk.

type Time

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

Time is a SQLite3 Time that scans for the various timestamps values used by SQLite3 database drivers to store time.Time values.

func NewTime

func NewTime(t time.Time) Time

NewTime creates a time.

func (Time) Format

func (t Time) Format(layout string) string

Format formats the time.

func (*Time) Parse

func (t *Time) Parse(s string) error

Parse attempts to Parse string s to t.

func (*Time) Scan

func (t *Time) Scan(v interface{}) error

Scan satisfies the sql.Scanner interface.

func (Time) String

func (t Time) String() string

String satisfies the fmt.Stringer interface.

func (Time) Time

func (t Time) Time() time.Time

Time returns a time.Time.

func (Time) Value

func (t Time) Value() (driver.Value, error)

Value satisfies the sql/driver.Valuer interface.

type User

type User struct {
	ID    string `json:"id"`    // id
	Login string `json:"login"` // login
	// contains filtered or unexported fields
}

User represents a row from 'users'.

func UserByID

func UserByID(ctx context.Context, db DB, id string) (*User, error)

UserByID retrieves a row from 'users' as a User.

Generated from index 'sqlite_autoindex_users_1'.

func (*User) Delete

func (u *User) Delete(ctx context.Context, db DB) error

Delete deletes the User from the database.

func (*User) Deleted

func (u *User) Deleted() bool

Deleted returns true when the User has been marked for deletion from the database.

func (*User) Exists

func (u *User) Exists() bool

Exists returns true when the User exists in the database.

func (*User) Insert

func (u *User) Insert(ctx context.Context, db DB) error

Insert inserts the User to the database.

func (*User) Save

func (u *User) Save(ctx context.Context, db DB) error

Save saves the User to the database.

func (*User) Update

func (u *User) Update(ctx context.Context, db DB) error

Update updates a User in the database.

func (*User) Upsert

func (u *User) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for User.

type Vertex

type Vertex struct {
	RunID     string         `json:"run_id"`     // run_id
	Digest    string         `json:"digest"`     // digest
	Name      string         `json:"name"`       // name
	Cached    int            `json:"cached"`     // cached
	StartTime *Time          `json:"start_time"` // start_time
	EndTime   *Time          `json:"end_time"`   // end_time
	Error     sql.NullString `json:"error"`      // error
	// contains filtered or unexported fields
}

Vertex represents a row from 'vertexes'.

func VertexByRunIDDigest

func VertexByRunIDDigest(ctx context.Context, db DB, runID, digest string) (*Vertex, error)

VertexByRunIDDigest retrieves a row from 'vertexes' as a Vertex.

Generated from index 'sqlite_autoindex_vertexes_1'.

func VertexesByRunID

func VertexesByRunID(ctx context.Context, db DB, runID string) ([]*Vertex, error)

VertexesByRunID retrieves a row from 'vertexes' as a Vertex.

Generated from index 'idx_vertexes_run_id'.

func (*Vertex) Delete

func (v *Vertex) Delete(ctx context.Context, db DB) error

Delete deletes the Vertex from the database.

func (*Vertex) Deleted

func (v *Vertex) Deleted() bool

Deleted returns true when the Vertex has been marked for deletion from the database.

func (*Vertex) Exists

func (v *Vertex) Exists() bool

Exists returns true when the Vertex exists in the database.

func (*Vertex) Insert

func (v *Vertex) Insert(ctx context.Context, db DB) error

Insert inserts the Vertex to the database.

func (*Vertex) Run

func (v *Vertex) Run(ctx context.Context, db DB) (*Run, error)

Run returns the Run associated with the Vertex's (RunID).

Generated from foreign key 'vertexes_run_id_fkey'.

func (*Vertex) Save

func (v *Vertex) Save(ctx context.Context, db DB) error

Save saves the Vertex to the database.

func (*Vertex) Update

func (v *Vertex) Update(ctx context.Context, db DB) error

Update updates a Vertex in the database.

func (*Vertex) Upsert

func (v *Vertex) Upsert(ctx context.Context, db DB) error

Upsert performs an upsert for Vertex.

type VertexEdge

type VertexEdge struct {
	SourceDigest string `json:"source_digest"` // source_digest
	TargetDigest string `json:"target_digest"` // target_digest
	// contains filtered or unexported fields
}

VertexEdge represents a row from 'vertex_edges'.

func VertexEdgeBySourceDigestTargetDigest

func VertexEdgeBySourceDigestTargetDigest(ctx context.Context, db DB, sourceDigest, targetDigest string) (*VertexEdge, error)

VertexEdgeBySourceDigestTargetDigest retrieves a row from 'vertex_edges' as a VertexEdge.

Generated from index 'sqlite_autoindex_vertex_edges_1'.

func VertexEdgesBySourceDigest

func VertexEdgesBySourceDigest(ctx context.Context, db DB, sourceDigest string) ([]*VertexEdge, error)

VertexEdgesBySourceDigest retrieves a row from 'vertex_edges' as a VertexEdge.

Generated from index 'idx_vertex_edges_source_digest'.

func VertexEdgesByTargetDigest

func VertexEdgesByTargetDigest(ctx context.Context, db DB, targetDigest string) ([]*VertexEdge, error)

VertexEdgesByTargetDigest retrieves a row from 'vertex_edges' as a VertexEdge.

Generated from index 'idx_vertex_edges_target_digest'.

func (*VertexEdge) Delete

func (ve *VertexEdge) Delete(ctx context.Context, db DB) error

Delete deletes the VertexEdge from the database.

func (*VertexEdge) Deleted

func (ve *VertexEdge) Deleted() bool

Deleted returns true when the VertexEdge has been marked for deletion from the database.

func (*VertexEdge) Exists

func (ve *VertexEdge) Exists() bool

Exists returns true when the VertexEdge exists in the database.

func (*VertexEdge) Insert

func (ve *VertexEdge) Insert(ctx context.Context, db DB) error

Insert inserts the VertexEdge to the database.

func (*VertexEdge) Thunk

func (ve *VertexEdge) Thunk(ctx context.Context, db DB) (*Thunk, error)

Thunk returns the Thunk associated with the VertexEdge's (TargetDigest).

Generated from foreign key 'vertex_edges_target_digest_fkey'.

Jump to

Keyboard shortcuts

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