Documentation
¶
Index ¶
- Constants
- Variables
- func LoadStruct(src interface{}, data map[string]interface{}) error
- func ParseKey(str string) (*datastore.Key, error)
- func RegisterDialect(driver string, d Dialect)
- func SaveStruct(src interface{}) (map[string]Property, error)
- func SetPKSimple(flag bool)
- func StringKey(key *datastore.Key) string
- func StringifyKey(key *datastore.Key) string
- type CharSet
- type Client
- func (c Client) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c Client) PrepareExec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (c Client) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (c Client) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- type Column
- type Config
- type Cursor
- type DB
- func (db *DB) Ancestor(ancestor *datastore.Key) *Query
- func (db *DB) AnyOfAncestor(ancestors ...*datastore.Key) *Query
- func (db *DB) Close() error
- func (db *DB) Create(ctx context.Context, model interface{}, parentKey ...*datastore.Key) error
- func (db *DB) Delete(ctx context.Context, model interface{}) error
- func (db *DB) Destroy(ctx context.Context, model interface{}) error
- func (db *DB) Exec(ctx context.Context, stmt string, args ...interface{}) (sql.Result, error)
- func (db *DB) Find(ctx context.Context, key *datastore.Key, model interface{}) error
- func (db *DB) First(ctx context.Context, model interface{}) error
- func (db *DB) Get(ctx context.Context, model interface{}) error
- func (db DB) ID() string
- func (db *DB) MatchAgainst(fields []string, value ...string) *Query
- func (db *DB) Migrate(ctx context.Context, model ...interface{}) error
- func (db DB) Name() string
- func (db *DB) NewQuery() *Query
- func (db *DB) Omit(fields ...string) Replacer
- func (db *DB) Paginate(ctx context.Context, p *Pagination, model interface{}) error
- func (db *DB) Query(ctx context.Context, stmt string, args ...interface{}) (*sql.Rows, error)
- func (db *DB) Replica(ctx context.Context, driver string, conf ReplicaConfig) error
- func (db *DB) ReplicaPingInterval(seconds int64) error
- func (db *DB) RunInTransaction(cb TransactionHandler) error
- func (db *DB) Save(ctx context.Context, model interface{}) error
- func (db *DB) Select(fields ...string) *Query
- func (db *DB) Table(name string) *Table
- func (db *DB) Truncate(ctx context.Context, model ...interface{}) error
- func (db *DB) Upsert(ctx context.Context, model interface{}, parentKey ...*datastore.Key) error
- func (db *DB) Where(field string, operator string, value interface{}) *Query
- type Date
- type DefaultEncoder
- type DefaultStmtEncoder
- type Dialect
- type Filter
- type Iterator
- type JSON
- type Loader
- type LogHandler
- type NativeHandler
- type OmitDefault
- type Pagination
- type Property
- type Query
- func (q *Query) Ancestor(ancestor *datastore.Key) *Query
- func (q *Query) AnyOfAncestor(ancestors ...*datastore.Key) *Query
- func (q *Query) DistinctOn(fields ...string) *Query
- func (q *Query) Find(ctx context.Context, key *datastore.Key, model interface{}) error
- func (q *Query) First(ctx context.Context, model interface{}) error
- func (q *Query) Flush(ctx context.Context) error
- func (q *Query) Get(ctx context.Context, model interface{}) error
- func (q *Query) IgnoreResolution() *Query
- func (q *Query) InjectResolution(ctx context.Context) context.Context
- func (q *Query) InsertInto(ctx context.Context, table string) error
- func (q *Query) Limit(limit int) *Query
- func (q *Query) Lock(mode locked) *Query
- func (q *Query) MatchAgainst(fields []string, values ...string) *Query
- func (q *Query) Offset(offset int) *Query
- func (q *Query) Omit(fields ...string) *Query
- func (q *Query) OrderBy(values ...interface{}) *Query
- func (q *Query) Paginate(ctx context.Context, p *Pagination, model interface{}) error
- func (q *Query) RLock() *Query
- func (q *Query) ReplaceInto(ctx context.Context, table string) error
- func (q *Query) ReplicaResolver(resolver replicaResolver) *Query
- func (q *Query) Scan(ctx context.Context, dest ...interface{}) error
- func (q *Query) Select(fields ...string) *Query
- func (q *Query) Unscoped() *Query
- func (q *Query) Update(ctx context.Context, v interface{}) error
- func (q *Query) WLock() *Query
- func (q *Query) Where(field string, op string, value interface{}) *Query
- func (q *Query) WhereAnyLike(field string, v interface{}) *Query
- func (q *Query) WhereEqual(field string, v interface{}) *Query
- func (q *Query) WhereIn(field string, v interface{}) *Query
- func (q *Query) WhereJSON(field, op string, v interface{}) *Query
- func (q *Query) WhereJSONContainAny(field string, v interface{}) *Query
- func (q *Query) WhereJSONEqual(field string, v interface{}) *Query
- func (q *Query) WhereJSONIn(field string, v []interface{}) *Query
- func (q *Query) WhereJSONIsArray(field string) *Query
- func (q *Query) WhereJSONIsObject(field string) *Query
- func (q *Query) WhereJSONNotEqual(field string, v interface{}) *Query
- func (q *Query) WhereJSONNotIn(field string, v []interface{}) *Query
- func (q *Query) WhereJSONType(field, typ string) *Query
- func (q *Query) WhereLike(field, v string) *Query
- func (q *Query) WhereNotEqual(field string, v interface{}) *Query
- func (q *Query) WhereNotIn(field string, v interface{}) *Query
- func (q *Query) WhereNotLike(field, v string) *Query
- func (q *Query) WhereNotNull(field string) *Query
- func (q *Query) WhereNull(field string) *Query
- type QueryBuilder
- type Registry
- type Replacer
- type ReplicaConfig
- type Saver
- type Schema
- type SoftDelete
- type Stmt
- type StmtRegistry
- type StructCodec
- type Table
- func (t *Table) AddIndex(ctx context.Context, fields ...string) error
- func (t *Table) AddUniqueIndex(ctx context.Context, fields ...string) error
- func (t *Table) Ancestor(ancestor *datastore.Key) *Query
- func (t *Table) AnyOfAncestor(ancestors ...*datastore.Key) *Query
- func (t *Table) Create(ctx context.Context, model interface{}, parentKey ...*datastore.Key) error
- func (t *Table) DistinctOn(fields ...string) *Query
- func (t *Table) DropIfExists(ctx context.Context) error
- func (t *Table) Exists(ctx context.Context) bool
- func (t *Table) Find(ctx context.Context, key *datastore.Key, model interface{}) error
- func (t *Table) First(ctx context.Context, model interface{}) error
- func (t *Table) Get(ctx context.Context, model interface{}) error
- func (t *Table) InsertInto(ctx context.Context, table string) error
- func (t *Table) Limit(limit int) *Query
- func (t *Table) Lock(mode locked) *Query
- func (t *Table) Migrate(ctx context.Context, model interface{}) error
- func (t *Table) Offset(offset int) *Query
- func (t *Table) Omit(fields ...string) *Query
- func (t *Table) OrderBy(fields ...interface{}) *Query
- func (t *Table) Paginate(ctx context.Context, p *Pagination, model interface{}) error
- func (t *Table) RLock() *Query
- func (t *Table) ReplaceInto(ctx context.Context, table string) error
- func (t *Table) Save(ctx context.Context, model interface{}) error
- func (t *Table) Scan(ctx context.Context, dest ...interface{}) error
- func (t *Table) Select(fields ...string) *Query
- func (t *Table) Truncate(ctx context.Context) error
- func (t *Table) Unscoped() *Query
- func (t *Table) Update(ctx context.Context, v interface{}) error
- func (t *Table) Upsert(ctx context.Context, model interface{}, parentKey ...*datastore.Key) error
- func (t *Table) WLock() *Query
- func (t *Table) Where(field, op string, value interface{}) *Query
- func (t *Table) WhereEqual(field string, v interface{}) *Query
- func (t *Table) WhereIn(field string, v []interface{}) *Query
- func (t *Table) WhereJSONEqual(field string, v interface{}) *Query
- func (t *Table) WhereLike(field, v string) *Query
- func (t *Table) WhereNotEqual(field string, v interface{}) *Query
- func (t *Table) WhereNotIn(field string, v []interface{}) *Query
- func (t *Table) WhereNotLike(field, v string) *Query
- func (t *Table) WhereNotNull(field string) *Query
- func (t *Table) WhereNull(field string) *Query
- type TransactionHandler
- type Writer
Constants ¶
const ( Equal operator = iota EqualTo NotEqual LessThan LessEqual GreaterThan GreaterEqual AnyLike Like NotLike ContainAny ContainAll In NotIn IsObject IsArray IsType MatchAgainst )
JSON :
const ( ReadLock locked = iota + 1 WriteLock )
lock mode
const ( DefaultReplicaResolver replicaResolver = iota ReplicaResolvePrimaryOnly ReplicaResolveSecondaryOnly ReplicaResolveReadOnly )
Variables ¶
var ( ErrNoSuchEntity = fmt.Errorf("goloquent: entity not found") ErrInvalidCursor = fmt.Errorf("goloquent: invalid cursor") )
CommonError :
Functions ¶
Types ¶
type Client ¶
type Client struct { CharSet // contains filtered or unexported fields }
Client :
func (Client) PrepareExec ¶
func (c Client) PrepareExec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
PrepareExec :
type Config ¶
type Config struct { Username string Password string Host string Port string Database string UnixSocket string TLSConfig string CharSet *CharSet Logger LogHandler Native NativeHandler }
Config :
type Cursor ¶
type Cursor struct { Signature string `json:"signature"` Key *datastore.Key `json:"next"` // contains filtered or unexported fields }
Cursor :
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB :
func NewDB ¶
func NewDB(ctx context.Context, driver string, charset CharSet, conn sqlCommon, dialect Dialect, logHandler LogHandler) *DB
NewDB :
func (*DB) AnyOfAncestor ¶
AnyOfAncestor :
func (*DB) MatchAgainst ¶
Where :
func (*DB) Paginate ¶
func (db *DB) Paginate(ctx context.Context, p *Pagination, model interface{}) error
Paginate :
func (*DB) ReplicaPingInterval ¶ added in v1.0.4
func (*DB) RunInTransaction ¶
func (db *DB) RunInTransaction(cb TransactionHandler) error
RunInTransaction :
type DefaultEncoder ¶
type DefaultEncoder struct {
// contains filtered or unexported fields
}
type DefaultStmtEncoder ¶
type DefaultStmtEncoder struct {
// contains filtered or unexported fields
}
type Dialect ¶
type Dialect interface { Open(c Config) (*sql.DB, error) SetDB(db Client) GetTable(ns string) string Version(ctx context.Context) (ver string) CurrentDB(ctx context.Context) (n string) Quote(n string) string Bind(i uint) string FilterJSON(f Filter) (s string, args []interface{}, err error) JSONMarshal(i interface{}) (b json.RawMessage) Value(v interface{}) string GetSchema(c Column) []Schema DataType(s Schema) string HasTable(ctx context.Context, tb string) bool HasIndex(ctx context.Context, tb, idx string) bool GetColumns(ctx context.Context, tb string) (cols []string) GetIndexes(ctx context.Context, tb string) (idxs []string) CreateTable(ctx context.Context, tb string, cols []Column) error AlterTable(ctx context.Context, tb string, cols []Column, unsafe bool) error OnConflictUpdate(tb string, cols []string) string UpdateWithLimit() bool ReplaceInto(ctx context.Context, src, dst string) error }
Dialect :
type Pagination ¶
Pagination :
func (*Pagination) Count ¶
func (p *Pagination) Count() uint
Count : record count in this pagination record set
func (*Pagination) NextCursor ¶
func (p *Pagination) NextCursor() string
NextCursor : next record set cursor
func (*Pagination) Reset ¶
func (p *Pagination) Reset()
Reset : reset all the value in pagination to default value
type Property ¶
type Property struct { Value interface{} // contains filtered or unexported fields }
Property :
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query :
func (*Query) AnyOfAncestor ¶
AnyOfAncestor :
func (*Query) IgnoreResolution ¶ added in v1.0.1
IgnoreResolution :
func (*Query) InjectResolution ¶ added in v1.0.1
func (*Query) InsertInto ¶
InsertInto :
func (*Query) MatchAgainst ¶
MatchAgainst :
func (*Query) Paginate ¶
func (q *Query) Paginate(ctx context.Context, p *Pagination, model interface{}) error
Paginate :
func (*Query) ReplaceInto ¶
ReplaceInto :
func (*Query) ReplicaResolver ¶ added in v1.0.2
Unscoped :
func (*Query) WhereAnyLike ¶
WhereAnyLike :
func (*Query) WhereEqual ¶
WhereEqual :
func (*Query) WhereJSONContainAny ¶
WhereJSONContainAny :
func (*Query) WhereJSONEqual ¶
WhereJSONEqual :
func (*Query) WhereJSONIn ¶
WhereJSONIn :
func (*Query) WhereJSONIsArray ¶
WhereJSONIsArray :
func (*Query) WhereJSONIsObject ¶
WhereJSONIsObject :
func (*Query) WhereJSONNotEqual ¶
WhereJSONNotEqual :
func (*Query) WhereJSONNotIn ¶
WhereJSONNotIn :
func (*Query) WhereJSONType ¶
WhereJSONType :
func (*Query) WhereNotEqual ¶
WhereNotEqual :
func (*Query) WhereNotIn ¶
WhereNotIn :
type Registry ¶
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) SetDefaultEncoders ¶
func (r *Registry) SetDefaultEncoders()
func (*Registry) SetKindEncoder ¶
func (*Registry) SetTypeEncoder ¶
type Replacer ¶
type Replacer interface { Upsert(ctx context.Context, model interface{}, k ...*datastore.Key) error Save(ctx context.Context, model interface{}) error }
Replacer :
type ReplicaConfig ¶ added in v1.0.2
type Schema ¶
type Schema struct { Name string DataType string DefaultValue interface{} IsUnsigned bool IsNullable bool IsIndexed bool CharSet }
Schema :
type StmtRegistry ¶
func NewStmtRegistry ¶
func NewStmtRegistry() *StmtRegistry
func (*StmtRegistry) BuildStatement ¶
func (r *StmtRegistry) BuildStatement(w Writer, v reflect.Value) ([]interface{}, error)
func (*StmtRegistry) SetDefaultEncoders ¶
func (r *StmtRegistry) SetDefaultEncoders()
func (*StmtRegistry) SetKindEncoder ¶
func (r *StmtRegistry) SetKindEncoder(k reflect.Kind, f writerFunc)
func (*StmtRegistry) SetTypeEncoder ¶
func (r *StmtRegistry) SetTypeEncoder(t reflect.Type, f writerFunc)
type StructCodec ¶
type StructCodec struct {
// contains filtered or unexported fields
}
StructCodec :
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table :
func (*Table) AddUniqueIndex ¶
AddUniqueIndex :
func (*Table) AnyOfAncestor ¶
AnyOfAncestor :
func (*Table) InsertInto ¶
InsertInto :
func (*Table) Paginate ¶
func (t *Table) Paginate(ctx context.Context, p *Pagination, model interface{}) error
Paginate :
func (*Table) ReplaceInto ¶
ReplaceInto :
func (*Table) WhereEqual ¶
WhereEqual :
func (*Table) WhereJSONEqual ¶
WhereJSONEqual :
func (*Table) WhereNotEqual ¶
WhereNotEqual :
func (*Table) WhereNotIn ¶
WhereNotIn :
type Writer ¶
type Writer interface { io.Writer io.StringWriter io.ByteWriter }
Source Files
¶
- builder.go
- cache.go
- cursor.go
- date.go
- db.go
- decoder.go
- dialect.go
- dialect_mysql.go
- dialect_postgres.go
- dialect_sequel.go
- enc.go
- encoder.go
- entity.go
- filter.go
- iterator.go
- paginator.go
- query.go
- query_builder.go
- replica.go
- schema.go
- statement.go
- stmtblr.go
- struct_codec.go
- struct_tag.go
- table.go
- utils.go