Documentation
¶
Index ¶
- Constants
- func Migrate(dataDir string, db dbx.IDatabase, failOnOrderMismatch bool, ...) error
- func PageHandler(q dbx.IQuery, page ...*pages.Page) dbx.IQuery
- func WrapPageHandler(q dbx.IQuery, result interface{}, page ...*pages.Page) (*pages.Paginated, error)
- type AbstractQuery
- func (a *AbstractQuery) Limit(n int) dbx.IQuery
- func (a *AbstractQuery) Not(query interface{}, args ...interface{}) dbx.IQuery
- func (a *AbstractQuery) Or() dbx.IQuery
- func (q *AbstractQuery) Page(page ...*pages.Page) dbx.IQuery
- func (a *AbstractQuery) Select(query interface{}, args ...interface{}) dbx.IQuery
- func (a *AbstractQuery) Skip(n int) dbx.IQuery
- func (a *AbstractQuery) Sort(fields ...string) dbx.IQuery
- func (a *AbstractQuery) Where(query interface{}, args ...interface{}) dbx.IQuery
- func (q *AbstractQuery) WrapPage(result interface{}, page ...*pages.Page) (*pages.Paginated, error)
- type AbstractQueryx
- func (a *AbstractQueryx) Limit(n int) dbx.IQuery
- func (a *AbstractQueryx) Not(query interface{}, args ...interface{}) dbx.IQuery
- func (a *AbstractQueryx) Or() dbx.IQuery
- func (a *AbstractQueryx) Select(query interface{}, args ...interface{}) dbx.IQuery
- func (a *AbstractQueryx) Skip(n int) dbx.IQuery
- func (a *AbstractQueryx) Sort(fields ...string) dbx.IQuery
- func (a *AbstractQueryx) Where(query interface{}, args ...interface{}) dbx.IQuery
- type Command
- type ConditionData
- type MigrationInfo
- type Migrator
Constants ¶
View Source
const (
MigrationRepo = "_migration"
)
Variables ¶
This section is empty.
Functions ¶
func Migrate ¶
func Migrate(dataDir string, db dbx.IDatabase, failOnOrderMismatch bool, repoIdSuffix ...string) error
Migrate begins a DB migration process by migrating the scripts located in the provided data dir and storing the migration track in a migration repository ('_migration' by default)
{dataDir} - The location where the migration scripts are contained {db} - The database client already initialized {failOnOrderMismatch} - Indicates whether the migration should fail if the order of previously migrated scripts have failed (removing or adding scripts between previously migrated scripts) {repoIdSuffix} - (optional) A suffix to use for the repository name where the migration data is stored. This is useful when sharing the same database instance with multiple services that own their unique repositories (tables in SQL, collections in MongoDB)
func PageHandler ¶
Types ¶
type AbstractQuery ¶
type AbstractQuery struct { Q dbx.IQuery LimitVal *int SkipVal *int SortFields []string Selects []*ConditionData Queries [][]*ConditionData }
AbstractQuery is a base query helper used for final implementations.
func (*AbstractQuery) Limit ¶
func (a *AbstractQuery) Limit(n int) dbx.IQuery
func (*AbstractQuery) Not ¶
func (a *AbstractQuery) Not(query interface{}, args ...interface{}) dbx.IQuery
func (*AbstractQuery) Or ¶
func (a *AbstractQuery) Or() dbx.IQuery
func (*AbstractQuery) Page ¶
func (q *AbstractQuery) Page(page ...*pages.Page) dbx.IQuery
Page adds to the query the information required to fetch the requested page of objects.
func (*AbstractQuery) Select ¶
func (a *AbstractQuery) Select(query interface{}, args ...interface{}) dbx.IQuery
func (*AbstractQuery) Skip ¶
func (a *AbstractQuery) Skip(n int) dbx.IQuery
func (*AbstractQuery) Sort ¶
func (a *AbstractQuery) Sort(fields ...string) dbx.IQuery
func (*AbstractQuery) Where ¶
func (a *AbstractQuery) Where(query interface{}, args ...interface{}) dbx.IQuery
type AbstractQueryx ¶
type AbstractQueryx struct { Q dbx.IQuery Commands []*Command }
AbstractQueryx is a base query helper used for final implementations.
func (*AbstractQueryx) Limit ¶
func (a *AbstractQueryx) Limit(n int) dbx.IQuery
func (*AbstractQueryx) Not ¶
func (a *AbstractQueryx) Not(query interface{}, args ...interface{}) dbx.IQuery
func (*AbstractQueryx) Or ¶
func (a *AbstractQueryx) Or() dbx.IQuery
func (*AbstractQueryx) Select ¶
func (a *AbstractQueryx) Select(query interface{}, args ...interface{}) dbx.IQuery
func (*AbstractQueryx) Skip ¶
func (a *AbstractQueryx) Skip(n int) dbx.IQuery
func (*AbstractQueryx) Sort ¶
func (a *AbstractQueryx) Sort(fields ...string) dbx.IQuery
func (*AbstractQueryx) Where ¶
func (a *AbstractQueryx) Where(query interface{}, args ...interface{}) dbx.IQuery
type ConditionData ¶
type ConditionData struct { Negation bool Query interface{} Args []interface{} }
type MigrationInfo ¶
type Migrator ¶ added in v1.0.2
type Migrator struct { // Db is the database client already initialized Db dbx.IDatabase // DataDir is the location where the migration scripts are contained DataDir string // FailOnOrderMismatch indicates whether the migration should fail if the order of previously migrated scripts FailOnOrderMismatch bool // RepoIdSuffix is an optional suffix to use for the repository name where the migration data is stored. This is // useful when sharing the same database instance with multiple services that own their unique repositories (tables // in SQL, collections in MongoDB) RepoIdSuffix string // ScriptExecutor is a custom script executor to run the scripts for a migration. If not provided uses `Db.Run` // // This custom executor is added for scenarios where Db.Run would not work as expected, for example using a MongoDB // client with AWS DocumentDB where `eval` is not supported, a custom executor using the `mongo` shell CLI could be // implemented instead. ScriptExecutor dbx.ScriptExecutor }
Click to show internal directories.
Click to hide internal directories.