Versions in this module Expand all Collapse all v1 v1.10.1 Nov 28, 2024 v1.10.0 Nov 28, 2024 Changes in this version + var EOF = io.EOF + var ErrEmptyFields = errors.New("empty fields") + var ErrExpectedStruct = errors.New("expected struct as a source") + var ErrInvalidCursor = errors.New("sqlike: invalid cursor") + var ErrInvalidInput = errors.New("sqlike: invalid input <nil>") + var ErrNilEntity = errors.New("sqlike: entity is <nil>") + var ErrNoColumn = errors.New("sqlike: no columns to create index") + var ErrNoRecordAffected = errors.New("no record affected") + var ErrNoRows = sql.ErrNoRows + var ErrNoValueUpdate = errors.New("sqlike: no value to update") + var ErrUnaddressableEntity = errors.New("sqlike: unaddressable entity") + type Client struct + func Connect(ctx context.Context, driver string, opt *options.ConnectOptions) (client *Client, err error) + func ConnectDB(ctx context.Context, driver string, conn driver.Connector) (*Client, error) + func MustConnect(ctx context.Context, driver string, opt *options.ConnectOptions) *Client + func MustConnectDB(ctx context.Context, driver string, conn driver.Connector) *Client + func MustOpen(ctx context.Context, driver string, opt *options.ConnectOptions) *Client + func Open(ctx context.Context, driver string, opt *options.ConnectOptions) (client *Client, err error) + func (c *Client) CreateDatabase(ctx context.Context, name string) error + func (c *Client) Database(name string, connections ...*options.ConnectOptions) *Database + func (c *Client) DropDatabase(ctx context.Context, name string) error + func (c *Client) ListDatabases(ctx context.Context) ([]string, error) + func (c *Client) SetCodec(cdc codec.Codecer) *Client + func (c *Client) SetLogger(logger logs.Logger) *Client + func (c *Client) SetPrimaryKey(pk string) *Client + func (c *Client) SetStructMapper(mapper reflext.StructMapper) *Client + type Column struct + Charset *string + Collation *string + Comment string + DataType string + DefaultValue *string + Extra string + IsNullable types.Boolean + Name string + Position int + Type string + type ColumnView struct + func (cv *ColumnView) DropOne(ctx context.Context, name string) error + func (cv *ColumnView) List(ctx context.Context) ([]Column, error) + func (cv *ColumnView) Rename(ctx context.Context, oldColName, newColName string) error + type Database struct + func (db *Database) BeginTransaction(ctx context.Context, opts ...*sql.TxOptions) (*Transaction, error) + func (db *Database) BuildIndexes(ctx context.Context, paths ...string) error + func (db *Database) Name() string + func (db *Database) QueryRow(ctx context.Context, query string, args ...interface{}) SingleResult + func (db *Database) QueryStmt(ctx context.Context, query interface{}) (*Result, error) + func (db *Database) RunInTransaction(ctx context.Context, cb txCallback, opts ...*options.TransactionOptions) error + func (db *Database) Table(name string) *Table + func (tb *Database) InjectResolution(ctx context.Context, queries ...primitive.Group) context.Context + type DriverInfo struct + func (d *DriverInfo) Charset() charset.Code + func (d *DriverInfo) Collate() string + func (d *DriverInfo) DriverName() string + func (d *DriverInfo) Version() *semver.Version + type Index struct + IsUnique bool + Name string + Type string + type IndexView struct + func (idv *IndexView) Create(ctx context.Context, idxs []indexes.Index) error + func (idv *IndexView) CreateIfNotExists(ctx context.Context, idxs []indexes.Index) error + func (idv *IndexView) CreateOne(ctx context.Context, idx indexes.Index) error + func (idv *IndexView) CreateOneIfNotExists(ctx context.Context, idx indexes.Index) error + func (idv *IndexView) DropAll(ctx context.Context) error + func (idv *IndexView) List(ctx context.Context) ([]Index, error) + func (idv IndexView) DropOne(ctx context.Context, name string) error + type Paginator struct + func (pg *Paginator) All(results interface{}) error + func (pg *Paginator) NextCursor(ctx context.Context, cursor interface{}) (err error) + type Result struct + func (r *Result) All(results interface{}) error + func (r *Result) Close() error + func (r *Result) ColumnTypes() ([]*sql.ColumnType, error) + func (r *Result) Columns() []string + func (r *Result) Decode(dst interface{}) error + func (r *Result) Error() error + func (r *Result) Next() bool + func (r *Result) NextResultSet() bool + func (r *Result) Scan(dests ...interface{}) error + func (r *Result) ScanSlice(results interface{}) error + type Resulter interface + Close func() error + Columns func() []string + Next func() bool + NextResultSet func() bool + Scan func(dests ...interface{}) error + type SessionContext interface + Exec func(query string, args ...interface{}) (sql.Result, error) + Prepare func(query string) (*sql.Stmt, error) + Query func(query string, args ...interface{}) (*sql.Rows, error) + QueryRow func(query string, args ...interface{}) *sql.Row + QueryStmt func(query interface{}) (*Result, error) + Table func(name string) *Table + type SingleResult interface + ColumnTypes func() ([]*sql.ColumnType, error) + Columns func() []string + Decode func(dest interface{}) error + Error func() error + Scan func(dest ...interface{}) error + type Table struct + func (tb *Table) Columns() *ColumnView + func (tb *Table) Delete(ctx context.Context, act actions.DeleteStatement, ...) (int64, error) + func (tb *Table) DeleteOne(ctx context.Context, act actions.DeleteOneStatement, ...) (int64, error) + func (tb *Table) DestroyOne(ctx context.Context, delete interface{}, opts ...*options.DestroyOneOptions) error + func (tb *Table) Exists(ctx context.Context) bool + func (tb *Table) Find(ctx context.Context, act actions.SelectStatement, opts ...*options.FindOptions) (*Result, error) + func (tb *Table) FindOne(ctx context.Context, act actions.SelectOneStatement, ...) SingleResult + func (tb *Table) HasIndexByName(ctx context.Context, name string) (bool, error) + func (tb *Table) Indexes() *IndexView + func (tb *Table) InjectResolution(ctx context.Context, queries ...primitive.Group) context.Context + func (tb *Table) Insert(ctx context.Context, src interface{}, opts ...*options.InsertOptions) (sql.Result, error) + func (tb *Table) InsertOne(ctx context.Context, src interface{}, opts ...*options.InsertOneOptions) (sql.Result, error) + func (tb *Table) ListColumns(ctx context.Context) ([]Column, error) + func (tb *Table) ListIndexes(ctx context.Context) ([]Index, error) + func (tb *Table) Migrate(ctx context.Context, entity interface{}) error + func (tb *Table) ModifyOne(ctx context.Context, update interface{}, opts ...*options.ModifyOneOptions) error + func (tb *Table) MustUnsafeMigrate(ctx context.Context, entity interface{}) + func (tb *Table) Paginate(ctx context.Context, act actions.PaginateStatement, ...) (*Paginator, error) + func (tb *Table) Rename(ctx context.Context, name string) error + func (tb *Table) Replace(ctx context.Context, fields []string, query *sql.SelectStmt) error + func (tb *Table) ReplaceOne(ctx context.Context, src interface{}, opts ...*options.InsertOneOptions) (sql.Result, error) + func (tb *Table) Truncate(ctx context.Context) (err error) + func (tb *Table) UnsafeMigrate(ctx context.Context, entity interface{}) error + func (tb *Table) Update(ctx context.Context, act actions.UpdateStatement, ...) (int64, error) + func (tb *Table) UpdateOne(ctx context.Context, act actions.UpdateOneStatement, ...) (int64, error) + func (tb Table) Drop(ctx context.Context) (err error) + func (tb Table) DropIfExists(ctx context.Context) (err error) + func (tb Table) MustMigrate(ctx context.Context, entity interface{}) + type Transaction struct + func (tx *Transaction) CommitTransaction() error + func (tx *Transaction) Exec(query string, args ...interface{}) (sql.Result, error) + func (tx *Transaction) Prepare(query string) (*sql.Stmt, error) + func (tx *Transaction) Query(query string, args ...interface{}) (*sql.Rows, error) + func (tx *Transaction) QueryRow(query string, args ...interface{}) *sql.Row + func (tx *Transaction) QueryStmt(query interface{}) (*Result, error) + func (tx *Transaction) RollbackTransaction() error + func (tx *Transaction) Table(name string) *Table