models

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package models contains generated code for schema 'Cookies'.

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 Convert added in v0.2.2

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

Convert converts a slice of Cookie to http.Cookie.

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 Cookie struct {
	HostKey        string         `json:"host_key"`        // host_key
	Name           string         `json:"name"`            // name
	EncryptedValue EncryptedValue `json:"encrypted_value"` // encrypted_value
	Path           string         `json:"path"`            // path
	ExpiresUTC     ExpiresUTC     `json:"expires_utc"`     // expires_utc
	IsSecure       bool           `json:"is_secure"`       // is_secure
	IsHTTPOnly     bool           `json:"is_http_only"`    // is_http_only
}

Cookie is a browser cookie.

func Cookies

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

Cookies retrieves cookies.

func CookiesLikeHost added in v0.2.2

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, ...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 'Cookies'.

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

type EncryptedValue

type EncryptedValue []byte

EncryptedValue wraps an encrypted value.

func (EncryptedValue) Bytes

func (v EncryptedValue) Bytes() []byte

Bytes returns the encrypted value as bytes.

func (*EncryptedValue) Scan

func (v *EncryptedValue) Scan(z interface{}) error

Scan satisfies the sql.Scanner interface.

func (EncryptedValue) String

func (v EncryptedValue) String() string

String satisfies the fmt.Stringer interface.

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 added in v0.2.3

type ErrUpsertFailed struct {
	Err error
}

ErrUpsertFailed is the upsert failed error.

func (*ErrUpsertFailed) Error added in v0.2.3

func (err *ErrUpsertFailed) Error() string

Error satisfies the error interface.

func (*ErrUpsertFailed) Unwrap added in v0.2.3

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 ExpiresUTC

type ExpiresUTC time.Time

ExpiresUTC wraps a UTC based expiry time.

func (*ExpiresUTC) Scan

func (v *ExpiresUTC) Scan(z interface{}) error

Scan satisfies the sql.Scanner interface.

func (ExpiresUTC) Time

func (v ExpiresUTC) Time() time.Time

Time returns the value as a standard time.

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.

Jump to

Keyboard shortcuts

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