models

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package models contains generated code for schema 'cookies.sqlite'.

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",

} // Cookie is a browser cookie.

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 Convert

func Convert(res []*Cookie) []*http.Cookie

Convert converts a slice of Cookie to http.Cookie.

func Errorf

func Errorf(s string, v ...any)

Errorf logs an error message using the package error logger.

func Logf

func Logf(s string, v ...any)

Logf logs a message using the package logger.

func SetErrorLogger

func SetErrorLogger(logger any)

SetErrorLogger sets the package error logger. Valid logger types:

io.Writer
func(string, ...any) (int, error) // fmt.Printf
func(string, ...any) // log.Printf

func SetLogger

func SetLogger(logger any)

SetLogger sets the package logger. Valid logger types:

io.Writer
func(string, ...any) (int, error) // fmt.Printf
func(string, ...any) // log.Printf

Types

type Cookie struct {
	Expiry     int64  `json:"expiry"`       // expiry
	Host       string `json:"host"`         // host
	Name       string `json:"name"`         // name
	Value      string `json:"value"`        // value
	Path       string `json:"path"`         // path
	IsSecure   bool   `json:"is_secure"`    // is_secure
	IsHTTPOnly bool   `json:"is_http_only"` // is_http_only
}

func Cookies

func Cookies(ctx context.Context, db DB, host string) ([]*Cookie, error)

Cookies retrieves cookies.

func CookiesLikeHost

func CookiesLikeHost(ctx context.Context, db DB, host string) ([]*Cookie, error)

CookiesLikeHost retrieves cookies like the host.

type DB

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

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

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 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) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the [json.Marshaler] interface.

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 any) 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) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

UnmarshalJSON satisfies the [json.Unmarshaler] interface.

func (Time) Value

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

Value satisfies the sql/driver.Valuer interface.

Jump to

Keyboard shortcuts

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