Documentation
¶
Index ¶
- Constants
- Variables
- func CreateAddRelationQuery(relationshipTable, id, relationshipID string, idValue, relationshipIDValue any) (string, pgx.NamedArgs)
- func CreateAggregateQuery(list []*WhereList, model Model, aggregate *Aggregate) (string, pgx.NamedArgs)
- func CreateBulkInsertQuery(args pgx.NamedArgs, fieldsList []map[string]any, fieldsListList [][]string) (string, string)
- func CreateInsertQuery(fields map[string]any, fieldsList []string) (string, string, pgx.NamedArgs)
- func CreateSelectListQuery(list []*WhereList, model Model, result Result, orders []*Order, paging *Paging) (string, []any, pgx.NamedArgs)
- func CreateSelectQuery(list []*WhereList, model Model, result Result) (string, []any, pgx.NamedArgs)
- func CreateUpdateQuery(fields map[string]any, fieldsList []string) (string, pgx.NamedArgs)
- func DeleteRelationQuery(relationshipTable, id, relationshipID string, idValue, relationshipIDValue any) (string, pgx.NamedArgs)
- func IsExistRelationQuery(relationshipTable, id, relationshipID string, idValue, relationshipIDValue any) (string, pgx.NamedArgs)
- func ScanFirstRow(rows pgx.Rows, model Model, selectedAddress []any) error
- func ScanListFirstRow(rows pgx.Rows, model Model, selectedAddress []any) error
- func ScanListNextRows(rows pgx.Rows, model Model, selectedAddress []any) error
- func ScanNextRows(rows pgx.Rows, model Model, selectedAddress []any) error
- func ScanValues(rows pgx.Rows, selectedAddress []any) error
- type Aggregate
- func (a *Aggregate) Avg(field string, value any)
- func (a *Aggregate) Count(field string, value any)
- func (a *Aggregate) Field(field string, value any)
- func (a *Aggregate) GroupBy(tableName string)
- func (a *Aggregate) Max(field string, value any)
- func (a *Aggregate) Min(field string, value any)
- func (a *Aggregate) Sum(field string, value any)
- type Client
- func (receiver *Client) AddManyToManyRelation(ctx context.Context, relationshipTable, id, relationshipID string, ...) error
- func (receiver *Client) Aggregate(ctx context.Context, list []*WhereList, model Model, aggregate *Aggregate) (func() error, error)
- func (receiver *Client) BulkCreate(ctx context.Context, tableName string, fieldsList []map[string]any, ...) error
- func (receiver *Client) BulkDelete(ctx context.Context, tableName string, idName string, idValue []any) error
- func (receiver *Client) BulkUpdate(ctx context.Context, tableName string, fields map[string]any, ...) error
- func (receiver *Client) Create(ctx context.Context, tableName string, fields map[string]any, ...) error
- func (receiver *Client) Delete(ctx context.Context, tableName string, idName string, idValue any) error
- func (receiver *Client) DeleteManyToManyRelation(ctx context.Context, relationshipTable, id, relationshipID string, ...) error
- func (receiver *Client) ExistManyToManyRelation(ctx context.Context, relationshipTable, id, relationshipID string, ...) (bool, error)
- func (receiver *Client) Get(ctx context.Context, list []*WhereList, model Model, result Result) error
- func (receiver *Client) List(ctx context.Context, list []*WhereList, model Model, result Result, ...) error
- func (receiver *Client) Refresh(ctx context.Context, model Model, result Result, idName string, idValue any) error
- func (receiver *Client) Update(ctx context.Context, tableName string, fields map[string]any, ...) error
- type DatabaseClient
- type DatabaseTransactionClient
- type Model
- type OperationInfo
- type OperationType
- type Order
- type Paging
- type Relation
- type RelationCondition
- type RelationJoinType
- type RelationList
- type RelationModel
- type Res
- type Result
- type SelectedField
- type Where
- type WhereList
Constants ¶
View Source
const ( EQ = "\"%s\".\"%s\" = %s" NEQ = "\"%s\".\"%s\" != %s" GT = "\"%s\".\"%s\" > %s" GTE = "\"%s\".\"%s\" >= %s" LT = "\"%s\".\"%s\" < %s" LTE = "\"%s\".\"%s\" <= %s" NIL = "\"%s\".\"%s\" IS NIL" NNIL = "\"%s\".\"%s\" IS NOT NIL" ANY = "\"%s\".\"%s\" = ANY(%s)" NANY = "\"%s\".\"%s\" != ANY(%s)" )
Variables ¶
View Source
var ErrFinalRow = errors.New("there is no new row")
View Source
var NotFoundError = errors.New("not found")
Functions ¶
func CreateAddRelationQuery ¶
func CreateAggregateQuery ¶
func CreateBulkInsertQuery ¶ added in v0.2.0
func CreateInsertQuery ¶
func CreateSelectListQuery ¶
func CreateSelectQuery ¶
func CreateUpdateQuery ¶
func DeleteRelationQuery ¶
func IsExistRelationQuery ¶
func ScanFirstRow ¶
func ScanListFirstRow ¶
func ScanListNextRows ¶
func ScanNextRows ¶
func ScanValues ¶
Types ¶
type Client ¶
type Client struct {
Database DatabaseClient
}
func NewClient ¶
func NewClient(d DatabaseClient) *Client
func (*Client) AddManyToManyRelation ¶
func (*Client) BulkCreate ¶ added in v0.2.0
func (*Client) BulkDelete ¶ added in v0.2.0
func (*Client) BulkUpdate ¶ added in v0.2.0
func (*Client) DeleteManyToManyRelation ¶
func (*Client) ExistManyToManyRelation ¶
type DatabaseClient ¶
type Model ¶
type Model interface { GetDBName() string GetRelationList() *RelationList ScanResult() SetResult(result Result) }
type OperationInfo ¶
type OperationInfo struct { TableName string OperationType OperationType }
func NewOperationInfo ¶
func NewOperationInfo(tableName string, operationType OperationType) *OperationInfo
type OperationType ¶
type OperationType string
const ( OperationTypeGet OperationType = "GET" OperationTypeRefresh OperationType = "REFRESH" OperationTypeCreate OperationType = "CREATE" OperationTypeUpdate OperationType = "UPDATE" OperationTypeDelete OperationType = "DELETE" OperationTypeList OperationType = "LIST" OperationTypeBulkCreate OperationType = "BULK_CREATE" OperationTypeBulkUpdate OperationType = "BULK_UPDATE" OperationTypeBulkDelete OperationType = "BULK_DELETE" )
type Relation ¶
type Relation struct { RelationModel Model RelationResult Result RelationTable string RelationWhere *RelationCondition RelationJoinType RelationJoinType Where []*WhereList ManyToManyTable string }
func (*Relation) SetJoinType ¶ added in v0.3.0
func (r *Relation) SetJoinType(t RelationJoinType) *Relation
type RelationCondition ¶
func (*RelationCondition) String ¶
func (r *RelationCondition) String(tableName, relationTableName string) string
type RelationJoinType ¶ added in v0.3.0
type RelationJoinType string
const ( RelationJoinTypeDefault RelationJoinType = "" RelationJoinTypeLeft RelationJoinType = "LEFT" RelationJoinTypeRight RelationJoinType = "RIGHT" RelationJoinTypeFull RelationJoinType = "FULL" RelationJoinTypeInner RelationJoinType = "INNER" )
type RelationList ¶
type RelationModel ¶
type Result ¶
type Result interface { GetDBName() string GetSelectedFields() []*SelectedField GetRelations() []Result IsExist() bool }
type SelectedField ¶
type Where ¶
func (*Where) GetSqlString ¶
Click to show internal directories.
Click to hide internal directories.