db

package
v0.0.0-...-32b26f9 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: GPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FtsQuery

func FtsQuery(query, prefix string) string

FtsQuery takes a user-generated query string and formats as a query suitable for postgresql's ts_query(). It does its level best to sanitize user input.

Basic Algorithm:

  • Split query into fields where fields contain characters conforming to unicode.isLetter() and unicode.isNumber(). All other characters are treated as field separators and discarded.
  • Fields which conform to [Prefix][Number] (case insensitive) are striped of the prefix and any leading zeros and used as an alternate to the field. ex: T01001 -> (T01001:* | 1001:*)
  • All fields are treated as a prefix search by appending ':*'
  • Fields are explicitly ANDed together
  • ex: 'hsa01040 fat' -> '(hsa01040:* | 1040:*) & fat:*'

Types

type ChunkResult

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

func (ChunkResult) LastInsertId

func (p ChunkResult) LastInsertId() (int64, error)

LastInsertId foo

func (ChunkResult) RowsAffected

func (p ChunkResult) RowsAffected() (int64, error)

RowsAffected foo

type DB

type DB struct {
	*sqlx.DB
	Host     string `mapstructure:"host"`
	Database string `mapstructure:"database"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
}

func (*DB) Chunk

func (p *DB) Chunk(chunkSize int, query string, arg interface{}) (sql.Result, error)

Chunk foo

func (*DB) ExecAll

func (p *DB) ExecAll(queries []string) (err error)

func (*DB) NamedGet

func (p *DB) NamedGet(dest interface{}, query string, arg interface{}) error

func (*DB) NamedSelect

func (p *DB) NamedSelect(dest interface{}, query string, arg interface{}) error

func (*DB) Open

func (p *DB) Open() (err error)

type NullString

type NullString sql.NullString

func (*NullString) MarshalJSON

func (p *NullString) MarshalJSON() ([]byte, error)

MarshalJSON foo

func (*NullString) Scan

func (p *NullString) Scan(value interface{}) error

func (*NullString) UnmarshalJSON

func (p *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON foo

func (NullString) Value

func (p NullString) Value() (driver.Value, error)

type RedisPool

type RedisPool struct {
	*redis.Pool
	Address string `mapstructure:"address"`
}

func (*RedisPool) Open

func (p *RedisPool) Open()

type RedisStore

type RedisStore struct {
	rs.Store
	AuthenticationKey string `mapstructure:"auth-key"`
	EncryptionKey     string `mapstructure:"enc-key"`
}

func (*RedisStore) Open

func (p *RedisStore) Open(pool *RedisPool) error

Jump to

Keyboard shortcuts

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