model

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Code generated by pqt. source: cmd/appg/main.go DO NOT EDIT!

Index

Examples

Constants

View Source
const (
	TableCategory                     = "example.category"
	TableCategoryColumnContent        = "content"
	TableCategoryColumnCreatedAt      = "created_at"
	TableCategoryColumnID             = "id"
	TableCategoryColumnName           = "name"
	TableCategoryColumnParentID       = "parent_id"
	TableCategoryColumnUpdatedAt      = "updated_at"
	TableCategoryConstraintPrimaryKey = "example.category_id_pkey"

	TableCategoryConstraintParentIDForeignKey = "example.category_parent_id_fkey"

	TableCategoryConstraintNameIndex = "example.category_name_idx"
)
View Source
const (
	TablePackage                     = "example.package"
	TablePackageColumnBreak          = "break"
	TablePackageColumnCategoryID     = "category_id"
	TablePackageColumnCreatedAt      = "created_at"
	TablePackageColumnID             = "id"
	TablePackageColumnUpdatedAt      = "updated_at"
	TablePackageConstraintPrimaryKey = "example.package_id_pkey"

	TablePackageConstraintCategoryIDForeignKey = "example.package_category_id_fkey"
)
View Source
const (
	TableNews                        = "example.news"
	TableNewsColumnContent           = "content"
	TableNewsColumnContinue          = "continue"
	TableNewsColumnCreatedAt         = "created_at"
	TableNewsColumnID                = "id"
	TableNewsColumnLead              = "lead"
	TableNewsColumnMetaData          = "meta_data"
	TableNewsColumnScore             = "score"
	TableNewsColumnTitle             = "title"
	TableNewsColumnUpdatedAt         = "updated_at"
	TableNewsColumnVersion           = "version"
	TableNewsColumnViewsDistribution = "views_distribution"
	TableNewsConstraintPrimaryKey    = "example.news_id_pkey"

	TableNewsConstraintTitleUnique = "example.news_title_key"

	TableNewsConstraintTitleLeadUnique = "example.news_title_lead_key"
)
View Source
const (
	TableComment                              = "example.comment"
	TableCommentColumnContent                 = "content"
	TableCommentColumnCreatedAt               = "created_at"
	TableCommentColumnID                      = "id"
	TableCommentColumnIDMultiply              = "id_multiply"
	TableCommentColumnNewsID                  = "news_id"
	TableCommentColumnNewsTitle               = "news_title"
	TableCommentColumnRightNow                = "right_now"
	TableCommentColumnUpdatedAt               = "updated_at"
	TableCommentConstraintNewsTitleForeignKey = "example.comment_news_title_fkey"

	TableCommentConstraintNewsTitleIndex = "example.comment_news_title_idx"

	TableCommentConstraintNewsIDForeignKey = "example.comment_news_id_fkey"
)
View Source
const (
	TableComplete                                 = "example.complete"
	TableCompleteColumnColumnBool                 = "column_bool"
	TableCompleteColumnColumnBytea                = "column_bytea"
	TableCompleteColumnColumnCharacter0           = "column_character_0"
	TableCompleteColumnColumnCharacter100         = "column_character_100"
	TableCompleteColumnColumnDecimal              = "column_decimal"
	TableCompleteColumnColumnDoubleArray0         = "column_double_array_0"
	TableCompleteColumnColumnDoubleArray100       = "column_double_array_100"
	TableCompleteColumnColumnInteger              = "column_integer"
	TableCompleteColumnColumnIntegerArray0        = "column_integer_array_0"
	TableCompleteColumnColumnIntegerArray100      = "column_integer_array_100"
	TableCompleteColumnColumnIntegerBig           = "column_integer_big"
	TableCompleteColumnColumnIntegerBigArray0     = "column_integer_big_array_0"
	TableCompleteColumnColumnIntegerBigArray100   = "column_integer_big_array_100"
	TableCompleteColumnColumnIntegerSmall         = "column_integer_small"
	TableCompleteColumnColumnIntegerSmallArray0   = "column_integer_small_array_0"
	TableCompleteColumnColumnIntegerSmallArray100 = "column_integer_small_array_100"
	TableCompleteColumnColumnJson                 = "column_json"
	TableCompleteColumnColumnJsonNn               = "column_json_nn"
	TableCompleteColumnColumnJsonNnD              = "column_json_nn_d"
	TableCompleteColumnColumnJsonb                = "column_jsonb"
	TableCompleteColumnColumnJsonbNn              = "column_jsonb_nn"
	TableCompleteColumnColumnJsonbNnD             = "column_jsonb_nn_d"
	TableCompleteColumnColumnNumeric              = "column_numeric"
	TableCompleteColumnColumnReal                 = "column_real"
	TableCompleteColumnColumnSerial               = "column_serial"
	TableCompleteColumnColumnSerialBig            = "column_serial_big"
	TableCompleteColumnColumnSerialSmall          = "column_serial_small"
	TableCompleteColumnColumnText                 = "column_text"
	TableCompleteColumnColumnTextArray0           = "column_text_array_0"
	TableCompleteColumnColumnTextArray100         = "column_text_array_100"
	TableCompleteColumnColumnTimestamp            = "column_timestamp"
	TableCompleteColumnColumnTimestamptz          = "column_timestamptz"
	TableCompleteColumnColumnUUID                 = "column_uuid"
)
View Source
const (
	JoinDoNot = iota
	JoinInner
	JoinLeft
	JoinRight
	JoinCross
)
View Source
const SQL = `` /* 3138-byte string literal not displayed */

/ SQL ...

Variables

View Source
var (
	// Space is a shorthand composition option that holds space.
	Space = &CompositionOpts{
		Joint: " ",
	}
	// And is a shorthand composition option that holds AND operator.
	And = &CompositionOpts{
		Joint: " AND ",
	}
	// Or is a shorthand composition option that holds OR operator.
	Or = &CompositionOpts{
		Joint: " OR ",
	}
	// Comma is a shorthand composition option that holds comma.
	Comma = &CompositionOpts{
		Joint: ", ",
	}
)

Functions

func CategoryCriteriaWhereClause added in v0.12.0

func CategoryCriteriaWhereClause(comp *Composer, c *CategoryCriteria, id int) error

func CommentCriteriaWhereClause added in v0.12.0

func CommentCriteriaWhereClause(comp *Composer, c *CommentCriteria, id int) error

func CompleteCriteriaWhereClause added in v0.12.0

func CompleteCriteriaWhereClause(comp *Composer, c *CompleteCriteria, id int) error

func ErrorConstraint added in v0.11.0

func ErrorConstraint(err error) string

ErrorConstraint returns the error constraint of err if it was produced by the pq library. Otherwise, it returns empty string.

Example
expected := "pq: something goes wrong"
err := &pq.Error{
	Table:      "user",
	Constraint: expected,
}

switch ErrorConstraint(err) {
case expected:
	fmt.Println("expected constraint")
default:
	fmt.Println("unknown constraint")
}
Output:

expected constraint

func NewsCriteriaWhereClause added in v0.12.0

func NewsCriteriaWhereClause(comp *Composer, c *NewsCriteria, id int) error

func PackageCriteriaWhereClause added in v0.12.0

func PackageCriteriaWhereClause(comp *Composer, c *PackageCriteria, id int) error

Types

type CategoryCountExpr added in v0.12.0

type CategoryCountExpr struct {
	Where *CategoryCriteria
}

type CategoryCriteria

type CategoryCriteria struct {
	Content   sql.NullString
	CreatedAt pq.NullTime
	ID        sql.NullInt64
	Name      sql.NullString
	ParentID  sql.NullInt64
	UpdatedAt pq.NullTime
	// contains filtered or unexported fields
}

func CategoryAnd added in v0.21.0

func CategoryAnd(operands ...*CategoryCriteria) *CategoryCriteria

func CategoryOperand added in v0.21.0

func CategoryOperand(operator string, operands ...*CategoryCriteria) *CategoryCriteria

func CategoryOr added in v0.21.0

func CategoryOr(operands ...*CategoryCriteria) *CategoryCriteria

type CategoryEntity

type CategoryEntity struct {
	// Content ...
	Content string
	// CreatedAt ...
	CreatedAt time.Time
	// ID ...
	ID int64
	// Name ...
	Name string
	// ParentID ...
	ParentID sql.NullInt64
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// ChildCategory ...
	ChildCategory []*CategoryEntity
	// ParentCategory ...
	ParentCategory *CategoryEntity
	// Packages ...
	Packages []*PackageEntity
}

CategoryEntity ...

func ScanCategoryRows

func ScanCategoryRows(rows Rows) (entities []*CategoryEntity, err error)

ScanCategoryRows helps to scan rows straight to the slice of entities.

func (*CategoryEntity) Prop

func (e *CategoryEntity) Prop(cn string) (interface{}, bool)

func (*CategoryEntity) Props

func (e *CategoryEntity) Props(cns ...string) ([]interface{}, error)

type CategoryFindExpr added in v0.12.0

type CategoryFindExpr struct {
	Where         *CategoryCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
}

type CategoryIterator

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

CategoryIterator is not thread safe.

func (*CategoryIterator) Category

func (i *CategoryIterator) Category() (*CategoryEntity, error)

func (*CategoryIterator) Close

func (i *CategoryIterator) Close() error

func (*CategoryIterator) Columns

func (i *CategoryIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*CategoryIterator) Ent

func (i *CategoryIterator) Ent() (interface{}, error)

Ent is wrapper around Category method that makes iterator more generic.

func (*CategoryIterator) Err

func (i *CategoryIterator) Err() error

func (*CategoryIterator) Next

func (i *CategoryIterator) Next() bool

type CategoryJoin added in v0.12.0

type CategoryJoin struct {
	On, Where *CategoryCriteria
	Fetch     bool
	Kind      JoinType
}

type CategoryPatch

type CategoryPatch struct {
	Content   sql.NullString
	CreatedAt pq.NullTime
	Name      sql.NullString
	ParentID  sql.NullInt64
	UpdatedAt pq.NullTime
}

type CategoryRepositoryBase

type CategoryRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*CategoryRepositoryBase) Count

func (*CategoryRepositoryBase) DeleteOneByID

func (r *CategoryRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*CategoryRepositoryBase) Find

func (*CategoryRepositoryBase) FindIter

func (*CategoryRepositoryBase) FindOneByID

func (r *CategoryRepositoryBase) FindOneByID(ctx context.Context, pk int64) (*CategoryEntity, error)

func (*CategoryRepositoryBase) FindQuery added in v0.11.0

func (r *CategoryRepositoryBase) FindQuery(fe *CategoryFindExpr) (string, []interface{}, error)

func (*CategoryRepositoryBase) Insert

func (*CategoryRepositoryBase) InsertQuery added in v0.11.0

func (r *CategoryRepositoryBase) InsertQuery(e *CategoryEntity, read bool) (string, []interface{}, error)

func (*CategoryRepositoryBase) UpdateOneByID

func (r *CategoryRepositoryBase) UpdateOneByID(ctx context.Context, pk int64, p *CategoryPatch) (*CategoryEntity, error)

func (*CategoryRepositoryBase) UpdateOneByIDQuery added in v0.11.0

func (r *CategoryRepositoryBase) UpdateOneByIDQuery(pk int64, p *CategoryPatch) (string, []interface{}, error)

func (*CategoryRepositoryBase) Upsert

func (*CategoryRepositoryBase) UpsertQuery added in v0.11.0

func (r *CategoryRepositoryBase) UpsertQuery(e *CategoryEntity, p *CategoryPatch, inf ...string) (string, []interface{}, error)

type CommentCountExpr added in v0.12.0

type CommentCountExpr struct {
	Where           *CommentCriteria
	JoinNewsByTitle *NewsJoin
	JoinNewsByID    *NewsJoin
}

type CommentCriteria

type CommentCriteria struct {
	Content    sql.NullString
	CreatedAt  pq.NullTime
	ID         sql.NullInt64
	IDMultiply sql.NullInt64
	NewsID     sql.NullInt64
	NewsTitle  sql.NullString
	RightNow   pq.NullTime
	UpdatedAt  pq.NullTime
	// contains filtered or unexported fields
}

func CommentAnd added in v0.21.0

func CommentAnd(operands ...*CommentCriteria) *CommentCriteria

func CommentOperand added in v0.21.0

func CommentOperand(operator string, operands ...*CommentCriteria) *CommentCriteria

func CommentOr added in v0.21.0

func CommentOr(operands ...*CommentCriteria) *CommentCriteria

type CommentEntity

type CommentEntity struct {
	// Content ...
	Content string
	// CreatedAt ...
	CreatedAt time.Time
	// ID ...
	ID sql.NullInt64
	// IDMultiply ...
	// IDMultiply is read only
	IDMultiply int64
	// NewsID ...
	NewsID int64
	// NewsTitle ...
	NewsTitle string
	// RightNow ...
	// RightNow is read only
	RightNow time.Time
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// NewsByTitle ...
	NewsByTitle *NewsEntity
	// NewsByID ...
	NewsByID *NewsEntity
}

CommentEntity ...

func ScanCommentRows

func ScanCommentRows(rows Rows) (entities []*CommentEntity, err error)

ScanCommentRows helps to scan rows straight to the slice of entities.

func (*CommentEntity) Prop

func (e *CommentEntity) Prop(cn string) (interface{}, bool)

func (*CommentEntity) Props

func (e *CommentEntity) Props(cns ...string) ([]interface{}, error)

type CommentFindExpr added in v0.12.0

type CommentFindExpr struct {
	Where           *CommentCriteria
	Offset, Limit   int64
	Columns         []string
	OrderBy         []RowOrder
	JoinNewsByTitle *NewsJoin
	JoinNewsByID    *NewsJoin
}

type CommentIterator

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

CommentIterator is not thread safe.

func (*CommentIterator) Close

func (i *CommentIterator) Close() error

func (*CommentIterator) Columns

func (i *CommentIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*CommentIterator) Comment

func (i *CommentIterator) Comment() (*CommentEntity, error)

func (*CommentIterator) Ent

func (i *CommentIterator) Ent() (interface{}, error)

Ent is wrapper around Comment method that makes iterator more generic.

func (*CommentIterator) Err

func (i *CommentIterator) Err() error

func (*CommentIterator) Next

func (i *CommentIterator) Next() bool

type CommentJoin added in v0.12.0

type CommentJoin struct {
	On, Where       *CommentCriteria
	Fetch           bool
	Kind            JoinType
	JoinNewsByTitle *NewsJoin
	JoinNewsByID    *NewsJoin
}

type CommentPatch

type CommentPatch struct {
	Content    sql.NullString
	CreatedAt  pq.NullTime
	ID         sql.NullInt64
	IDMultiply sql.NullInt64
	NewsID     sql.NullInt64
	NewsTitle  sql.NullString
	RightNow   pq.NullTime
	UpdatedAt  pq.NullTime
}

type CommentRepositoryBase

type CommentRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*CommentRepositoryBase) Count

func (*CommentRepositoryBase) Find

func (*CommentRepositoryBase) FindIter

func (*CommentRepositoryBase) FindQuery added in v0.11.0

func (r *CommentRepositoryBase) FindQuery(fe *CommentFindExpr) (string, []interface{}, error)

func (*CommentRepositoryBase) Insert

func (*CommentRepositoryBase) InsertQuery added in v0.11.0

func (r *CommentRepositoryBase) InsertQuery(e *CommentEntity, read bool) (string, []interface{}, error)

func (*CommentRepositoryBase) Upsert

func (*CommentRepositoryBase) UpsertQuery added in v0.11.0

func (r *CommentRepositoryBase) UpsertQuery(e *CommentEntity, p *CommentPatch, inf ...string) (string, []interface{}, error)

type CompleteCountExpr added in v0.12.0

type CompleteCountExpr struct {
	Where *CompleteCriteria
}

type CompleteCriteria added in v0.11.0

type CompleteCriteria struct {
	ColumnBool                 sql.NullBool
	ColumnBytea                []byte
	ColumnCharacter0           sql.NullString
	ColumnCharacter100         sql.NullString
	ColumnDecimal              sql.NullFloat64
	ColumnDoubleArray0         NullFloat64Array
	ColumnDoubleArray100       NullFloat64Array
	ColumnInteger              *int32
	ColumnIntegerArray0        NullInt64Array
	ColumnIntegerArray100      NullInt64Array
	ColumnIntegerBig           sql.NullInt64
	ColumnIntegerBigArray0     NullInt64Array
	ColumnIntegerBigArray100   NullInt64Array
	ColumnIntegerSmall         *int16
	ColumnIntegerSmallArray0   NullInt64Array
	ColumnIntegerSmallArray100 NullInt64Array
	ColumnJson                 []byte
	ColumnJsonNn               []byte
	ColumnJsonNnD              []byte
	ColumnJsonb                []byte
	ColumnJsonbNn              []byte
	ColumnJsonbNnD             []byte
	ColumnNumeric              sql.NullFloat64
	ColumnReal                 *float32
	ColumnSerial               *int32
	ColumnSerialBig            sql.NullInt64
	ColumnSerialSmall          *int16
	ColumnText                 sql.NullString
	ColumnTextArray0           NullStringArray
	ColumnTextArray100         NullStringArray
	ColumnTimestamp            pq.NullTime
	ColumnTimestamptz          pq.NullTime
	ColumnUUID                 sql.NullString
	// contains filtered or unexported fields
}

func CompleteAnd added in v0.21.0

func CompleteAnd(operands ...*CompleteCriteria) *CompleteCriteria

func CompleteOperand added in v0.21.0

func CompleteOperand(operator string, operands ...*CompleteCriteria) *CompleteCriteria

func CompleteOr added in v0.21.0

func CompleteOr(operands ...*CompleteCriteria) *CompleteCriteria

type CompleteEntity added in v0.11.0

type CompleteEntity struct {
	// ColumnBool ...
	ColumnBool sql.NullBool
	// ColumnBytea ...
	ColumnBytea []byte
	// ColumnCharacter0 ...
	ColumnCharacter0 sql.NullString
	// ColumnCharacter100 ...
	ColumnCharacter100 sql.NullString
	// ColumnDecimal ...
	ColumnDecimal sql.NullFloat64
	// ColumnDoubleArray0 ...
	ColumnDoubleArray0 NullFloat64Array
	// ColumnDoubleArray100 ...
	ColumnDoubleArray100 NullFloat64Array
	// ColumnInteger ...
	ColumnInteger *int32
	// ColumnIntegerArray0 ...
	ColumnIntegerArray0 NullInt64Array
	// ColumnIntegerArray100 ...
	ColumnIntegerArray100 NullInt64Array
	// ColumnIntegerBig ...
	ColumnIntegerBig sql.NullInt64
	// ColumnIntegerBigArray0 ...
	ColumnIntegerBigArray0 NullInt64Array
	// ColumnIntegerBigArray100 ...
	ColumnIntegerBigArray100 NullInt64Array
	// ColumnIntegerSmall ...
	ColumnIntegerSmall *int16
	// ColumnIntegerSmallArray0 ...
	ColumnIntegerSmallArray0 NullInt64Array
	// ColumnIntegerSmallArray100 ...
	ColumnIntegerSmallArray100 NullInt64Array
	// ColumnJson ...
	ColumnJson []byte
	// ColumnJsonNn ...
	ColumnJsonNn []byte
	// ColumnJsonNnD ...
	ColumnJsonNnD []byte
	// ColumnJsonb ...
	ColumnJsonb []byte
	// ColumnJsonbNn ...
	ColumnJsonbNn []byte
	// ColumnJsonbNnD ...
	ColumnJsonbNnD []byte
	// ColumnNumeric ...
	ColumnNumeric sql.NullFloat64
	// ColumnReal ...
	ColumnReal *float32
	// ColumnSerial ...
	ColumnSerial *int32
	// ColumnSerialBig ...
	ColumnSerialBig sql.NullInt64
	// ColumnSerialSmall ...
	ColumnSerialSmall *int16
	// ColumnText ...
	ColumnText sql.NullString
	// ColumnTextArray0 ...
	ColumnTextArray0 NullStringArray
	// ColumnTextArray100 ...
	ColumnTextArray100 NullStringArray
	// ColumnTimestamp ...
	ColumnTimestamp pq.NullTime
	// ColumnTimestamptz ...
	ColumnTimestamptz pq.NullTime
	// ColumnUUID ...
	ColumnUUID sql.NullString
}

CompleteEntity ...

func ScanCompleteRows added in v0.11.0

func ScanCompleteRows(rows Rows) (entities []*CompleteEntity, err error)

ScanCompleteRows helps to scan rows straight to the slice of entities.

func (*CompleteEntity) Prop added in v0.11.0

func (e *CompleteEntity) Prop(cn string) (interface{}, bool)

func (*CompleteEntity) Props added in v0.11.0

func (e *CompleteEntity) Props(cns ...string) ([]interface{}, error)

type CompleteFindExpr added in v0.12.0

type CompleteFindExpr struct {
	Where         *CompleteCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
}

type CompleteIterator added in v0.11.0

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

CompleteIterator is not thread safe.

func (*CompleteIterator) Close added in v0.11.0

func (i *CompleteIterator) Close() error

func (*CompleteIterator) Columns added in v0.11.0

func (i *CompleteIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*CompleteIterator) Complete added in v0.11.0

func (i *CompleteIterator) Complete() (*CompleteEntity, error)

func (*CompleteIterator) Ent added in v0.11.0

func (i *CompleteIterator) Ent() (interface{}, error)

Ent is wrapper around Complete method that makes iterator more generic.

func (*CompleteIterator) Err added in v0.11.0

func (i *CompleteIterator) Err() error

func (*CompleteIterator) Next added in v0.11.0

func (i *CompleteIterator) Next() bool

type CompleteJoin added in v0.12.0

type CompleteJoin struct {
	On, Where *CompleteCriteria
	Fetch     bool
	Kind      JoinType
}

type CompletePatch added in v0.11.0

type CompletePatch struct {
	ColumnBool                 sql.NullBool
	ColumnBytea                []byte
	ColumnCharacter0           sql.NullString
	ColumnCharacter100         sql.NullString
	ColumnDecimal              sql.NullFloat64
	ColumnDoubleArray0         NullFloat64Array
	ColumnDoubleArray100       NullFloat64Array
	ColumnInteger              *int32
	ColumnIntegerArray0        NullInt64Array
	ColumnIntegerArray100      NullInt64Array
	ColumnIntegerBig           sql.NullInt64
	ColumnIntegerBigArray0     NullInt64Array
	ColumnIntegerBigArray100   NullInt64Array
	ColumnIntegerSmall         *int16
	ColumnIntegerSmallArray0   NullInt64Array
	ColumnIntegerSmallArray100 NullInt64Array
	ColumnJson                 []byte
	ColumnJsonNn               []byte
	ColumnJsonNnD              []byte
	ColumnJsonb                []byte
	ColumnJsonbNn              []byte
	ColumnJsonbNnD             []byte
	ColumnNumeric              sql.NullFloat64
	ColumnReal                 *float32
	ColumnSerial               *int32
	ColumnSerialBig            sql.NullInt64
	ColumnSerialSmall          *int16
	ColumnText                 sql.NullString
	ColumnTextArray0           NullStringArray
	ColumnTextArray100         NullStringArray
	ColumnTimestamp            pq.NullTime
	ColumnTimestamptz          pq.NullTime
	ColumnUUID                 sql.NullString
}

type CompleteRepositoryBase added in v0.11.0

type CompleteRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*CompleteRepositoryBase) Count added in v0.11.0

func (*CompleteRepositoryBase) Find added in v0.11.0

func (*CompleteRepositoryBase) FindIter added in v0.11.0

func (*CompleteRepositoryBase) FindQuery added in v0.11.0

func (r *CompleteRepositoryBase) FindQuery(fe *CompleteFindExpr) (string, []interface{}, error)

func (*CompleteRepositoryBase) Insert added in v0.11.0

func (*CompleteRepositoryBase) InsertQuery added in v0.11.0

func (r *CompleteRepositoryBase) InsertQuery(e *CompleteEntity, read bool) (string, []interface{}, error)

func (*CompleteRepositoryBase) Upsert added in v0.11.0

func (*CompleteRepositoryBase) UpsertQuery added in v0.11.0

func (r *CompleteRepositoryBase) UpsertQuery(e *CompleteEntity, p *CompletePatch, inf ...string) (string, []interface{}, error)

type Composer added in v0.11.0

type Composer struct {
	Dirty bool
	// contains filtered or unexported fields
}

Composer holds buffer, arguments and placeholders count. In combination with external buffet can be also used to also generate sub-queries. To do that simply write buffer to the parent buffer, composer will hold all arguments and remember number of last placeholder.

func NewComposer added in v0.11.0

func NewComposer(size int64) *Composer

NewComposer allocates new Composer with inner slice of arguments of given size.

func (*Composer) Add added in v0.11.0

func (c *Composer) Add(arg interface{})

Add appends list with new element.

func (*Composer) Args added in v0.11.0

func (c *Composer) Args() []interface{}

Args returns all arguments stored as a slice.

func (*Composer) Len added in v0.11.0

func (c *Composer) Len() int

Len returns number of arguments.

func (*Composer) Read added in v0.11.0

func (c *Composer) Read(b []byte) (int, error)

Read implements io Reader interface.

Example
com := NewComposer(0)
buf := bytes.NewBufferString("SELECT * FROM user")
arg := 1

// lets imagine that not always argument is present
if arg > 0 {
	_, _ = com.WriteString("age = ")
	_ = com.WritePlaceholder()
	com.Add(arg)
	com.Dirty = true // something was written, lets mark composer as dirty
}

if com.Dirty {
	buf.WriteString(" WHERE ")
	buf.ReadFrom(com)
}

fmt.Println(strings.TrimSpace(
	buf.String(),
))
fmt.Print(com.Args())
Output:

SELECT * FROM user WHERE age = $1
[1]

func (*Composer) ResetBuf added in v0.11.0

func (c *Composer) ResetBuf()

ResetBuf resets internal buffer.

func (*Composer) String added in v0.11.0

func (c *Composer) String() string

String implements fmt Stringer interface.

func (*Composer) Write added in v0.11.0

func (c *Composer) Write(b []byte) (int, error)

Write implements io Writer interface.

func (*Composer) WriteAlias added in v0.12.0

func (c *Composer) WriteAlias(i int) error

func (*Composer) WritePlaceholder added in v0.11.0

func (c *Composer) WritePlaceholder() error

WritePlaceholder writes appropriate placeholder to the query buffer based on current state of the composer.

func (*Composer) WriteString added in v0.11.0

func (c *Composer) WriteString(s string) (int, error)

WriteString appends the contents of s to the query buffer, growing the buffer as needed. The return value n is the length of s; err is always nil. If the buffer becomes too large, WriteString will panic with bytes ErrTooLarge.

type CompositionOpts added in v0.11.0

type CompositionOpts struct {
	Joint                           string
	PlaceholderFuncs, SelectorFuncs []string
	PlaceholderCast, SelectorCast   string
	IsJSON                          bool
	IsDynamic                       bool
}

CompositionOpts is a container for modification that can be applied.

type CompositionWriter added in v0.11.0

type CompositionWriter interface {
	// WriteComposition is a function that allow custom struct type to be used as a part of criteria.
	// It gives possibility to write custom query based on object that implements this interface.
	WriteComposition(string, *Composer, *CompositionOpts) error
}

CompositionWriter is a simple wrapper for WriteComposition function.

type JSONArrayFloat64 added in v0.11.0

type JSONArrayFloat64 []float64

JSONArrayFloat64 is a slice of int64s that implements necessary interfaces.

func (*JSONArrayFloat64) Scan added in v0.11.0

func (a *JSONArrayFloat64) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayFloat64) Value added in v0.11.0

func (a JSONArrayFloat64) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JSONArrayInt64 added in v0.11.0

type JSONArrayInt64 []int64

JSONArrayInt64 is a slice of int64s that implements necessary interfaces.

func (*JSONArrayInt64) Scan added in v0.11.0

func (a *JSONArrayInt64) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayInt64) Value added in v0.11.0

func (a JSONArrayInt64) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JSONArrayString added in v0.11.0

type JSONArrayString []string

JSONArrayString is a slice of strings that implements necessary interfaces.

func (*JSONArrayString) Scan added in v0.11.0

func (a *JSONArrayString) Scan(src interface{}) error

Scan satisfy sql.Scanner interface.

func (JSONArrayString) Value added in v0.11.0

func (a JSONArrayString) Value() (driver.Value, error)

Value satisfy driver.Valuer interface.

type JoinType added in v0.12.0

type JoinType int

func (JoinType) String added in v0.12.0

func (jt JoinType) String() string

type LogFunc added in v0.15.0

type LogFunc func(err error, ent, fnc, sql string, args ...interface{})

LogFunc represents function that can be passed into repository to log query result.

type NewsCountExpr added in v0.12.0

type NewsCountExpr struct {
	Where *NewsCriteria
}

type NewsCriteria

type NewsCriteria struct {
	Content           sql.NullString
	Continue          sql.NullBool
	CreatedAt         pq.NullTime
	ID                sql.NullInt64
	Lead              sql.NullString
	MetaData          []byte
	Score             sql.NullFloat64
	Title             sql.NullString
	UpdatedAt         pq.NullTime
	Version           sql.NullInt64
	ViewsDistribution NullFloat64Array
	// contains filtered or unexported fields
}

func NewsAnd added in v0.21.0

func NewsAnd(operands ...*NewsCriteria) *NewsCriteria

func NewsOperand added in v0.21.0

func NewsOperand(operator string, operands ...*NewsCriteria) *NewsCriteria

func NewsOr added in v0.21.0

func NewsOr(operands ...*NewsCriteria) *NewsCriteria

type NewsEntity

type NewsEntity struct {
	// Content ...
	Content string
	// Continue ...
	Continue bool
	// CreatedAt ...
	CreatedAt time.Time
	// ID ...
	ID int64
	// Lead ...
	Lead sql.NullString
	// MetaData ...
	MetaData []byte
	// Score ...
	Score float64
	// Title ...
	Title string
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// Version ...
	Version int64
	// ViewsDistribution ...
	ViewsDistribution NullFloat64Array
	// CommentsByNewsTitle ...
	CommentsByNewsTitle []*CommentEntity
	// Comments ...
	Comments []*CommentEntity
}

NewsEntity ...

func ScanNewsRows

func ScanNewsRows(rows Rows) (entities []*NewsEntity, err error)

ScanNewsRows helps to scan rows straight to the slice of entities.

func (*NewsEntity) Prop

func (e *NewsEntity) Prop(cn string) (interface{}, bool)

func (*NewsEntity) Props

func (e *NewsEntity) Props(cns ...string) ([]interface{}, error)

type NewsFindExpr added in v0.12.0

type NewsFindExpr struct {
	Where         *NewsCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
}

type NewsIterator

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

NewsIterator is not thread safe.

func (*NewsIterator) Close

func (i *NewsIterator) Close() error

func (*NewsIterator) Columns

func (i *NewsIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*NewsIterator) Ent

func (i *NewsIterator) Ent() (interface{}, error)

Ent is wrapper around News method that makes iterator more generic.

func (*NewsIterator) Err

func (i *NewsIterator) Err() error

func (*NewsIterator) News

func (i *NewsIterator) News() (*NewsEntity, error)

func (*NewsIterator) Next

func (i *NewsIterator) Next() bool

type NewsJoin added in v0.12.0

type NewsJoin struct {
	On, Where *NewsCriteria
	Fetch     bool
	Kind      JoinType
}

type NewsPatch

type NewsPatch struct {
	Content           sql.NullString
	Continue          sql.NullBool
	CreatedAt         pq.NullTime
	Lead              sql.NullString
	MetaData          []byte
	Score             sql.NullFloat64
	Title             sql.NullString
	UpdatedAt         pq.NullTime
	Version           sql.NullInt64
	ViewsDistribution NullFloat64Array
}

type NewsRepositoryBase

type NewsRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*NewsRepositoryBase) Count

func (*NewsRepositoryBase) DeleteOneByID

func (r *NewsRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*NewsRepositoryBase) Find

func (*NewsRepositoryBase) FindIter

func (*NewsRepositoryBase) FindOneByID

func (r *NewsRepositoryBase) FindOneByID(ctx context.Context, pk int64) (*NewsEntity, error)

func (*NewsRepositoryBase) FindOneByTitle

func (r *NewsRepositoryBase) FindOneByTitle(ctx context.Context, newsTitle string) (*NewsEntity, error)

func (*NewsRepositoryBase) FindOneByTitleAndLead

func (r *NewsRepositoryBase) FindOneByTitleAndLead(ctx context.Context, newsTitle string, newsLead string) (*NewsEntity, error)

func (*NewsRepositoryBase) FindQuery added in v0.11.0

func (r *NewsRepositoryBase) FindQuery(fe *NewsFindExpr) (string, []interface{}, error)

func (*NewsRepositoryBase) Insert

func (*NewsRepositoryBase) InsertQuery added in v0.11.0

func (r *NewsRepositoryBase) InsertQuery(e *NewsEntity, read bool) (string, []interface{}, error)

func (*NewsRepositoryBase) UpdateOneByID

func (r *NewsRepositoryBase) UpdateOneByID(ctx context.Context, pk int64, p *NewsPatch) (*NewsEntity, error)

func (*NewsRepositoryBase) UpdateOneByIDQuery added in v0.11.0

func (r *NewsRepositoryBase) UpdateOneByIDQuery(pk int64, p *NewsPatch) (string, []interface{}, error)

func (*NewsRepositoryBase) UpdateOneByTitle

func (r *NewsRepositoryBase) UpdateOneByTitle(ctx context.Context, newsTitle string, p *NewsPatch) (*NewsEntity, error)

func (*NewsRepositoryBase) UpdateOneByTitleAndLead

func (r *NewsRepositoryBase) UpdateOneByTitleAndLead(ctx context.Context, newsTitle string, newsLead string, p *NewsPatch) (*NewsEntity, error)

func (*NewsRepositoryBase) UpdateOneByTitleAndLeadQuery added in v0.11.0

func (r *NewsRepositoryBase) UpdateOneByTitleAndLeadQuery(newsTitle string, newsLead string, p *NewsPatch) (string, []interface{}, error)

func (*NewsRepositoryBase) UpdateOneByTitleQuery added in v0.11.0

func (r *NewsRepositoryBase) UpdateOneByTitleQuery(newsTitle string, p *NewsPatch) (string, []interface{}, error)

func (*NewsRepositoryBase) Upsert

func (r *NewsRepositoryBase) Upsert(ctx context.Context, e *NewsEntity, p *NewsPatch, inf ...string) (*NewsEntity, error)

func (*NewsRepositoryBase) UpsertQuery added in v0.11.0

func (r *NewsRepositoryBase) UpsertQuery(e *NewsEntity, p *NewsPatch, inf ...string) (string, []interface{}, error)

type NullBoolArray added in v0.11.0

type NullBoolArray struct {
	pq.BoolArray
	Valid bool
}

func (*NullBoolArray) Scan added in v0.11.0

func (n *NullBoolArray) Scan(value interface{}) error

type NullByteaArray added in v0.11.0

type NullByteaArray struct {
	pq.ByteaArray
	Valid bool
}

func (*NullByteaArray) Scan added in v0.11.0

func (n *NullByteaArray) Scan(value interface{}) error

type NullFloat64Array added in v0.11.0

type NullFloat64Array struct {
	pq.Float64Array
	Valid bool
}

func (*NullFloat64Array) Scan added in v0.11.0

func (n *NullFloat64Array) Scan(value interface{}) error

type NullInt64Array added in v0.11.0

type NullInt64Array struct {
	pq.Int64Array
	Valid bool
}

func (*NullInt64Array) Scan added in v0.11.0

func (n *NullInt64Array) Scan(value interface{}) error

type NullStringArray added in v0.11.0

type NullStringArray struct {
	pq.StringArray
	Valid bool
}

func (*NullStringArray) Scan added in v0.11.0

func (n *NullStringArray) Scan(value interface{}) error

type PackageCountExpr added in v0.12.0

type PackageCountExpr struct {
	Where        *PackageCriteria
	JoinCategory *CategoryJoin
}

type PackageCriteria

type PackageCriteria struct {
	Break      sql.NullString
	CategoryID sql.NullInt64
	CreatedAt  pq.NullTime
	ID         sql.NullInt64
	UpdatedAt  pq.NullTime
	// contains filtered or unexported fields
}

func PackageAnd added in v0.21.0

func PackageAnd(operands ...*PackageCriteria) *PackageCriteria

func PackageOperand added in v0.21.0

func PackageOperand(operator string, operands ...*PackageCriteria) *PackageCriteria

func PackageOr added in v0.21.0

func PackageOr(operands ...*PackageCriteria) *PackageCriteria

type PackageEntity

type PackageEntity struct {
	// Break ...
	Break sql.NullString
	// CategoryID ...
	CategoryID sql.NullInt64
	// CreatedAt ...
	CreatedAt time.Time
	// ID ...
	ID int64
	// UpdatedAt ...
	UpdatedAt pq.NullTime
	// Category ...
	Category *CategoryEntity
}

PackageEntity ...

func ScanPackageRows

func ScanPackageRows(rows Rows) (entities []*PackageEntity, err error)

ScanPackageRows helps to scan rows straight to the slice of entities.

func (*PackageEntity) Prop

func (e *PackageEntity) Prop(cn string) (interface{}, bool)

func (*PackageEntity) Props

func (e *PackageEntity) Props(cns ...string) ([]interface{}, error)

type PackageFindExpr added in v0.12.0

type PackageFindExpr struct {
	Where         *PackageCriteria
	Offset, Limit int64
	Columns       []string
	OrderBy       []RowOrder
	JoinCategory  *CategoryJoin
}

type PackageIterator

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

PackageIterator is not thread safe.

func (*PackageIterator) Close

func (i *PackageIterator) Close() error

func (*PackageIterator) Columns

func (i *PackageIterator) Columns() ([]string, error)

Columns is wrapper around sql.Rows.Columns method, that also cache output inside iterator.

func (*PackageIterator) Ent

func (i *PackageIterator) Ent() (interface{}, error)

Ent is wrapper around Package method that makes iterator more generic.

func (*PackageIterator) Err

func (i *PackageIterator) Err() error

func (*PackageIterator) Next

func (i *PackageIterator) Next() bool

func (*PackageIterator) Package

func (i *PackageIterator) Package() (*PackageEntity, error)

type PackageJoin added in v0.12.0

type PackageJoin struct {
	On, Where    *PackageCriteria
	Fetch        bool
	Kind         JoinType
	JoinCategory *CategoryJoin
}

type PackagePatch

type PackagePatch struct {
	Break      sql.NullString
	CategoryID sql.NullInt64
	CreatedAt  pq.NullTime
	UpdatedAt  pq.NullTime
}

type PackageRepositoryBase

type PackageRepositoryBase struct {
	Table   string
	Columns []string
	DB      *sql.DB
	Log     LogFunc
}

func (*PackageRepositoryBase) Count

func (*PackageRepositoryBase) DeleteOneByID

func (r *PackageRepositoryBase) DeleteOneByID(ctx context.Context, pk int64) (int64, error)

func (*PackageRepositoryBase) Find

func (*PackageRepositoryBase) FindIter

func (*PackageRepositoryBase) FindOneByID

func (r *PackageRepositoryBase) FindOneByID(ctx context.Context, pk int64) (*PackageEntity, error)

func (*PackageRepositoryBase) FindQuery added in v0.11.0

func (r *PackageRepositoryBase) FindQuery(fe *PackageFindExpr) (string, []interface{}, error)

func (*PackageRepositoryBase) Insert

func (*PackageRepositoryBase) InsertQuery added in v0.11.0

func (r *PackageRepositoryBase) InsertQuery(e *PackageEntity, read bool) (string, []interface{}, error)

func (*PackageRepositoryBase) UpdateOneByID

func (r *PackageRepositoryBase) UpdateOneByID(ctx context.Context, pk int64, p *PackagePatch) (*PackageEntity, error)

func (*PackageRepositoryBase) UpdateOneByIDQuery added in v0.11.0

func (r *PackageRepositoryBase) UpdateOneByIDQuery(pk int64, p *PackagePatch) (string, []interface{}, error)

func (*PackageRepositoryBase) Upsert

func (*PackageRepositoryBase) UpsertQuery added in v0.11.0

func (r *PackageRepositoryBase) UpsertQuery(e *PackageEntity, p *PackagePatch, inf ...string) (string, []interface{}, error)

type RowOrder added in v0.20.0

type RowOrder struct {
	Name       string
	Descending bool
}

type Rows added in v0.17.0

type Rows interface {
	io.Closer
	ColumnTypes() ([]*sql.ColumnType, error)
	Columns() ([]string, error)
	Err() error
	Next() bool
	NextResultSet() bool
	Scan(dest ...interface{}) error
}

Rows ...

Jump to

Keyboard shortcuts

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