db

package
v0.0.0-...-6ca86ac Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Code generated by protoc-gen-structify. DO NOT EDIT. source: example/case_one/db/blog.proto provider: postgres protoc-gen-structify: (version=v1.1.0, branch=main, revision=0176e1872838a373cdc0d8a630d16ecb748ed32d), build: (go=go1.22.6, date=2024-08-14T15:04:09+0300) protoc: 3.15.8

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when a record is not found.
	ErrRowNotFound = errors.New("row not found")
	// ErrNoTransaction is returned when a transaction is not provided.
	ErrNoTransaction = errors.New("no transaction provided")
	// ErrRowAlreadyExist is returned when a row already exist.
	ErrRowAlreadyExist = errors.New("row already exist")
	// ErrModelIsNil is returned when a relation model is nil.
	ErrModelIsNil = errors.New("model is nil")
)

Functions

func Dsn

func Dsn(host string, port int, user string, password string, dbname string, sslMode string, timeout int) string

Dsn builds the DSN string for the database connection. See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

func IsPgUniqueViolation

func IsPgUniqueViolation(err error) bool

IsPgCheckViolation returns true if the error is a postgres check violation.

func IsPgViolationError

func IsPgViolationError(err error) bool

IsPgCheckViolation returns true if the error is a postgres check violation.

func Open

func Open(dsn string, opts ...BlogDatabaseClientOption) (*sql.DB, error)

Open connects to the database and returns a *sql.DB. The caller is responsible for closing the database. The caller is responsible for calling db.Ping() to verify the connection. The caller is responsible for setting the connection pool options.

See https://golang.org/pkg/database/sql/#DB.SetMaxOpenConns See https://golang.org/pkg/database/sql/#DB.SetMaxIdleConns See https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime See https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime See https://golang.org/pkg/database/sql/#DB.Ping

func PgPrettyErr

func PgPrettyErr(err error) error

PgPrettyErr returns a pretty postgres error.

func TxFromContext

func TxFromContext(ctx context.Context) (*sql.Tx, bool)

TxFromContext returns the transaction from the context.

Types

type Address

type Address struct {
	Id        string `db:"id"`
	Street    string `db:"street"`
	City      string `db:"city"`
	State     int32  `db:"state"`
	Zip       int64  `db:"zip"`
	User      *User
	UserId    string     `db:"user_id"`
	CreatedAt time.Time  `db:"created_at"`
	UpdatedAt *time.Time `db:"updated_at"`
}

Address is a struct for the "addresses" table.

func (*Address) ScanRow

func (t *Address) ScanRow(r *sql.Row) error

ScanRow scans a row into a Address.

func (*Address) ScanRows

func (t *Address) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the Address.

func (*Address) TableName

func (t *Address) TableName() string

TableName returns the table name.

type AddressAdvancedDeletion

type AddressAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

AddressAdvancedDeletion is an interface for advanced deletion operations.

type AddressCRUDOperations

type AddressCRUDOperations interface {
	Create(ctx context.Context, model *Address, opts ...Option) (*string, error)
	Update(ctx context.Context, id string, updateData *AddressUpdate) error
	DeleteById(ctx context.Context, id string, opts ...Option) error
	FindById(ctx context.Context, id string, opts ...Option) (*Address, error)
}

AddressCRUDOperations is an interface for managing the addresses table.

type AddressFilters

type AddressFilters struct {
	Id     *string
	UserId *string
}

AddressFilters is a struct that holds filters for Address.

type AddressPaginationOperations

type AddressPaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*Address, *Paginator, error)
}

AddressPaginationOperations is an interface for pagination operations.

type AddressRawQueryOperations

type AddressRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

AddressRawQueryOperations is an interface for executing raw queries.

type AddressRelationLoading

type AddressRelationLoading interface {
	LoadUser(ctx context.Context, model *Address, builders ...*QueryBuilder) error
	LoadBatchUser(ctx context.Context, items []*Address, builders ...*QueryBuilder) error
}

AddressRelationLoading is an interface for loading relations.

type AddressSearchOperations

type AddressSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*Address, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*Address, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*Address, error)
}

AddressSearchOperations is an interface for searching the addresses table.

type AddressStorage

AddressStorage is a struct for the "addresses" table.

func NewAddressStorage

func NewAddressStorage(db *sql.DB) AddressStorage

NewAddressStorage returns a new addressStorage.

type AddressTableManager

type AddressTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

AddressTableManager is an interface for managing the addresses table.

type AddressUpdate

type AddressUpdate struct {
	Street    *string
	City      *string
	State     *int32
	Zip       *int64
	UserId    *string
	CreatedAt *time.Time
	UpdatedAt *time.Time
}

AddressUpdate is used to update an existing Address.

type AndCondition

type AndCondition struct {
	Where []FilterApplier
}

And returns a condition that combines the given conditions with AND.

func (AndCondition) Apply

func (c AndCondition) Apply(query sq.SelectBuilder) sq.SelectBuilder

And returns a condition that combines the given conditions with AND.

func (AndCondition) ApplyDelete

func (c AndCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

And returns a condition that combines the given conditions with AND.

type BetweenCondition

type BetweenCondition struct {
	Field string
	Min   interface{}
	Max   interface{}
}

BetweenCondition

func (BetweenCondition) Apply

Apply applies the condition to the query.

func (BetweenCondition) ApplyDelete

func (c BetweenCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type BlogDatabaseClientOption

type BlogDatabaseClientOption func(*BlogDatabaseClientOptions)

Option is a function that configures the BlogDatabaseClient.

func WithConnMaxIdleTime

func WithConnMaxIdleTime(connMaxIdleTime time.Duration) BlogDatabaseClientOption

WithConnMaxIdleTime sets the maximum amount of time a connection may be idle.

func WithMaxIdleConns

func WithMaxIdleConns(maxIdleConns int) BlogDatabaseClientOption

WithMaxIdleConns sets the maximum number of idle connections to the database.

func WithMaxLifetime

func WithMaxLifetime(maxLifetime time.Duration) BlogDatabaseClientOption

WithMaxLifetime sets the maximum amount of time a connection may be reused.

func WithMaxOpenConns

func WithMaxOpenConns(maxOpenConns int) BlogDatabaseClientOption

WithMaxOpenConns sets the maximum number of open connections to the database.

type BlogDatabaseClientOptions

type BlogDatabaseClientOptions struct {
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxIdleTime time.Duration
	MaxLifetime     time.Duration
}

BlogDatabaseClientOptions are the options for the BlogDatabaseClient.

type BlogStorages

type BlogStorages interface {
	// GetDeviceStorage returns the DeviceStorage store.
	GetDeviceStorage() DeviceStorage
	// GetPostStorage returns the PostStorage store.
	GetPostStorage() PostStorage
	// GetMessageStorage returns the MessageStorage store.
	GetMessageStorage() MessageStorage
	// GetUserStorage returns the UserStorage store.
	GetUserStorage() UserStorage
	// GetSettingStorage returns the SettingStorage store.
	GetSettingStorage() SettingStorage
	// GetAddressStorage returns the AddressStorage store.
	GetAddressStorage() AddressStorage
	// TxManager returns the transaction manager.
	TxManager() *TxManager
	// CreateTables creates the tables for all the stores.
	CreateTables(ctx context.Context) error
	// DropTables drops the tables for all the stores.
	DropTables(ctx context.Context) error
	// TruncateTables truncates the tables for all the stores.
	TruncateTables(ctx context.Context) error
	// UpgradeTables upgrades the tables for all the stores.
	UpgradeTables(ctx context.Context) error
}

BlogStorages is the interface for the BlogStorages.

func NewBlogStorages

func NewBlogStorages(db *sql.DB) BlogStorages

NewBlogStorages returns a new BlogStorages.

type CommentMeta

type CommentMeta struct {
	Ip      string `json:"ip"`
	Browser string `json:"browser"`
	Os      string `json:"os"`
}

Meta is a JSON type nested in another message.

func (*CommentMeta) Scan

func (m *CommentMeta) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*CommentMeta) Value

func (m *CommentMeta) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type Device

type Device struct {
	Name   string `db:"name"`
	Value  string `db:"value"`
	UserId string `db:"user_id"`
}

Device is a struct for the "devices" table.

func (*Device) ScanRow

func (t *Device) ScanRow(r *sql.Row) error

ScanRow scans a row into a Device.

func (*Device) ScanRows

func (t *Device) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the Device.

func (*Device) TableName

func (t *Device) TableName() string

TableName returns the table name.

type DeviceAdvancedDeletion

type DeviceAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

DeviceAdvancedDeletion is an interface for advanced deletion operations.

type DeviceCRUDOperations

type DeviceCRUDOperations interface {
	Create(ctx context.Context, model *Device, opts ...Option) error
	Update(ctx context.Context, id int64, updateData *DeviceUpdate) error
}

DeviceCRUDOperations is an interface for managing the devices table.

type DeviceFilters

type DeviceFilters struct {
	UserId *string
}

DeviceFilters is a struct that holds filters for Device.

type DevicePaginationOperations

type DevicePaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*Device, *Paginator, error)
}

DevicePaginationOperations is an interface for pagination operations.

type DeviceRawQueryOperations

type DeviceRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

DeviceRawQueryOperations is an interface for executing raw queries.

type DeviceRelationLoading

type DeviceRelationLoading interface {
}

DeviceRelationLoading is an interface for loading relations.

type DeviceSearchOperations

type DeviceSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*Device, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*Device, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*Device, error)
}

DeviceSearchOperations is an interface for searching the devices table.

type DeviceStorage

DeviceStorage is a struct for the "devices" table.

func NewDeviceStorage

func NewDeviceStorage(db *sql.DB) DeviceStorage

NewDeviceStorage returns a new deviceStorage.

type DeviceTableManager

type DeviceTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

DeviceTableManager is an interface for managing the devices table.

type DeviceUpdate

type DeviceUpdate struct {
	Name   *string
	Value  *string
	UserId *string
}

DeviceUpdate is used to update an existing Device.

type EqualsCondition

type EqualsCondition struct {
	Field string
	Value interface{}
}

EqualsCondition equals condition.

func (EqualsCondition) Apply

Apply applies the condition to the query.

func (EqualsCondition) ApplyDelete

func (c EqualsCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

type FilterApplier

type FilterApplier interface {
	Apply(query sq.SelectBuilder) sq.SelectBuilder
	ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder
}

FilterApplier is a condition filters.

func AddressIdBetween

func AddressIdBetween(min, max string) FilterApplier

AddressIdBetween between condition.

func AddressIdEq

func AddressIdEq(value string) FilterApplier

AddressIdEq returns a condition that checks if the field equals the value.

func AddressIdGT

func AddressIdGT(value string) FilterApplier

AddressIdGT greaterThanCondition than condition.

func AddressIdGTE

func AddressIdGTE(value string) FilterApplier

AddressIdGTE greater than or equal condition.

func AddressIdIn

func AddressIdIn(values ...interface{}) FilterApplier

AddressIdIn condition

func AddressIdLT

func AddressIdLT(value string) FilterApplier

AddressIdLT less than condition.

func AddressIdLTE

func AddressIdLTE(value string) FilterApplier

AddressIdLTE less than or equal condition.

func AddressIdLike

func AddressIdLike(value string) FilterApplier

AddressIdLike like condition %

func AddressIdNotEq

func AddressIdNotEq(value string) FilterApplier

AddressIdNotEq returns a condition that checks if the field equals the value.

func AddressIdNotIn

func AddressIdNotIn(values ...interface{}) FilterApplier

AddressIdNotIn not in condition

func AddressIdNotLike

func AddressIdNotLike(value string) FilterApplier

AddressIdNotLike not like condition

func AddressIdOrderBy

func AddressIdOrderBy(asc bool) FilterApplier

AddressIdOrderBy sorts the result in ascending order.

func AddressUserIdBetween

func AddressUserIdBetween(min, max string) FilterApplier

AddressUserIdBetween between condition.

func AddressUserIdEq

func AddressUserIdEq(value string) FilterApplier

AddressUserIdEq returns a condition that checks if the field equals the value.

func AddressUserIdGT

func AddressUserIdGT(value string) FilterApplier

AddressUserIdGT greaterThanCondition than condition.

func AddressUserIdGTE

func AddressUserIdGTE(value string) FilterApplier

AddressUserIdGTE greater than or equal condition.

func AddressUserIdIn

func AddressUserIdIn(values ...interface{}) FilterApplier

AddressUserIdIn condition

func AddressUserIdLT

func AddressUserIdLT(value string) FilterApplier

AddressUserIdLT less than condition.

func AddressUserIdLTE

func AddressUserIdLTE(value string) FilterApplier

AddressUserIdLTE less than or equal condition.

func AddressUserIdLike

func AddressUserIdLike(value string) FilterApplier

AddressUserIdLike like condition %

func AddressUserIdNotEq

func AddressUserIdNotEq(value string) FilterApplier

AddressUserIdNotEq returns a condition that checks if the field equals the value.

func AddressUserIdNotIn

func AddressUserIdNotIn(values ...interface{}) FilterApplier

AddressUserIdNotIn not in condition

func AddressUserIdNotLike

func AddressUserIdNotLike(value string) FilterApplier

AddressUserIdNotLike not like condition

func AddressUserIdOrderBy

func AddressUserIdOrderBy(asc bool) FilterApplier

AddressUserIdOrderBy sorts the result in ascending order.

func And

func And(conditions ...FilterApplier) FilterApplier

And returns a condition that combines the given conditions with AND.

func Between

func Between(field string, min, max interface{}) FilterApplier

Between returns a condition that checks if the field is between the min and max values.

func DeviceUserIdBetween

func DeviceUserIdBetween(min, max string) FilterApplier

DeviceUserIdBetween between condition.

func DeviceUserIdEq

func DeviceUserIdEq(value string) FilterApplier

DeviceUserIdEq returns a condition that checks if the field equals the value.

func DeviceUserIdGT

func DeviceUserIdGT(value string) FilterApplier

DeviceUserIdGT greaterThanCondition than condition.

func DeviceUserIdGTE

func DeviceUserIdGTE(value string) FilterApplier

DeviceUserIdGTE greater than or equal condition.

func DeviceUserIdIn

func DeviceUserIdIn(values ...interface{}) FilterApplier

DeviceUserIdIn condition

func DeviceUserIdLT

func DeviceUserIdLT(value string) FilterApplier

DeviceUserIdLT less than condition.

func DeviceUserIdLTE

func DeviceUserIdLTE(value string) FilterApplier

DeviceUserIdLTE less than or equal condition.

func DeviceUserIdLike

func DeviceUserIdLike(value string) FilterApplier

DeviceUserIdLike like condition %

func DeviceUserIdNotEq

func DeviceUserIdNotEq(value string) FilterApplier

DeviceUserIdNotEq returns a condition that checks if the field equals the value.

func DeviceUserIdNotIn

func DeviceUserIdNotIn(values ...interface{}) FilterApplier

DeviceUserIdNotIn not in condition

func DeviceUserIdNotLike

func DeviceUserIdNotLike(value string) FilterApplier

DeviceUserIdNotLike not like condition

func DeviceUserIdOrderBy

func DeviceUserIdOrderBy(asc bool) FilterApplier

DeviceUserIdOrderBy sorts the result in ascending order.

func Eq

func Eq(field string, value interface{}) FilterApplier

Eq returns a condition that checks if the field equals the value.

func GreaterThan

func GreaterThan(field string, value interface{}) FilterApplier

GreaterThan returns a condition that checks if the field equals the value.

func GreaterThanOrEq

func GreaterThanOrEq(field string, value interface{}) FilterApplier

GreaterThanOrEqual returns a condition that checks if the field equals the value.

func In

func In(field string, values ...interface{}) FilterApplier

In returns a condition that checks if the field is in the given values.

func IsNotNull

func IsNotNull(field string) FilterApplier

IsNotNull returns a condition that checks if the field is not null.

func IsNull

func IsNull(field string) FilterApplier

IsNull returns a condition that checks if the field is null.

func Join

func Join(joinType JoinType, table Table, on FilterApplier) FilterApplier

func LessThan

func LessThan(field string, value interface{}) FilterApplier

LessThan returns a condition that checks if the field equals the value.

func LessThanOrEq

func LessThanOrEq(field string, value interface{}) FilterApplier

func Like

func Like(field string, value interface{}) FilterApplier

Like returns a condition that checks if the field equals the value.

func MessageIdBetween

func MessageIdBetween(min, max string) FilterApplier

MessageIdBetween between condition.

func MessageIdEq

func MessageIdEq(value string) FilterApplier

MessageIdEq returns a condition that checks if the field equals the value.

func MessageIdGT

func MessageIdGT(value string) FilterApplier

MessageIdGT greaterThanCondition than condition.

func MessageIdGTE

func MessageIdGTE(value string) FilterApplier

MessageIdGTE greater than or equal condition.

func MessageIdIn

func MessageIdIn(values ...interface{}) FilterApplier

MessageIdIn condition

func MessageIdLT

func MessageIdLT(value string) FilterApplier

MessageIdLT less than condition.

func MessageIdLTE

func MessageIdLTE(value string) FilterApplier

MessageIdLTE less than or equal condition.

func MessageIdLike

func MessageIdLike(value string) FilterApplier

MessageIdLike like condition %

func MessageIdNotEq

func MessageIdNotEq(value string) FilterApplier

MessageIdNotEq returns a condition that checks if the field equals the value.

func MessageIdNotIn

func MessageIdNotIn(values ...interface{}) FilterApplier

MessageIdNotIn not in condition

func MessageIdNotLike

func MessageIdNotLike(value string) FilterApplier

MessageIdNotLike not like condition

func MessageIdOrderBy

func MessageIdOrderBy(asc bool) FilterApplier

MessageIdOrderBy sorts the result in ascending order.

func MessageToUserIdBetween

func MessageToUserIdBetween(min, max string) FilterApplier

MessageToUserIdBetween between condition.

func MessageToUserIdEq

func MessageToUserIdEq(value string) FilterApplier

MessageToUserIdEq returns a condition that checks if the field equals the value.

func MessageToUserIdGT

func MessageToUserIdGT(value string) FilterApplier

MessageToUserIdGT greaterThanCondition than condition.

func MessageToUserIdGTE

func MessageToUserIdGTE(value string) FilterApplier

MessageToUserIdGTE greater than or equal condition.

func MessageToUserIdIn

func MessageToUserIdIn(values ...interface{}) FilterApplier

MessageToUserIdIn condition

func MessageToUserIdLT

func MessageToUserIdLT(value string) FilterApplier

MessageToUserIdLT less than condition.

func MessageToUserIdLTE

func MessageToUserIdLTE(value string) FilterApplier

MessageToUserIdLTE less than or equal condition.

func MessageToUserIdLike

func MessageToUserIdLike(value string) FilterApplier

MessageToUserIdLike like condition %

func MessageToUserIdNotEq

func MessageToUserIdNotEq(value string) FilterApplier

MessageToUserIdNotEq returns a condition that checks if the field equals the value.

func MessageToUserIdNotIn

func MessageToUserIdNotIn(values ...interface{}) FilterApplier

MessageToUserIdNotIn not in condition

func MessageToUserIdNotLike

func MessageToUserIdNotLike(value string) FilterApplier

MessageToUserIdNotLike not like condition

func MessageToUserIdOrderBy

func MessageToUserIdOrderBy(asc bool) FilterApplier

MessageToUserIdOrderBy sorts the result in ascending order.

func NotEq

func NotEq(field string, value interface{}) FilterApplier

NotEq returns a condition that checks if the field equals the value.

func NotIn

func NotIn(field string, values ...interface{}) FilterApplier

NotIn returns a condition that checks if the field is not in the given values.

func NotLike

func NotLike(field string, value interface{}) FilterApplier

NotLike returns a condition that checks if the field equals the value.

func Or

func Or(conditions ...FilterApplier) FilterApplier

Or returns a condition that checks if any of the conditions are true.

func OrderBy

func OrderBy(column string, asc bool) FilterApplier

Apply applies the condition to the query.

func PostAuthorIdBetween

func PostAuthorIdBetween(min, max string) FilterApplier

PostAuthorIdBetween between condition.

func PostAuthorIdEq

func PostAuthorIdEq(value string) FilterApplier

PostAuthorIdEq returns a condition that checks if the field equals the value.

func PostAuthorIdGT

func PostAuthorIdGT(value string) FilterApplier

PostAuthorIdGT greaterThanCondition than condition.

func PostAuthorIdGTE

func PostAuthorIdGTE(value string) FilterApplier

PostAuthorIdGTE greater than or equal condition.

func PostAuthorIdIn

func PostAuthorIdIn(values ...interface{}) FilterApplier

PostAuthorIdIn condition

func PostAuthorIdLT

func PostAuthorIdLT(value string) FilterApplier

PostAuthorIdLT less than condition.

func PostAuthorIdLTE

func PostAuthorIdLTE(value string) FilterApplier

PostAuthorIdLTE less than or equal condition.

func PostAuthorIdLike

func PostAuthorIdLike(value string) FilterApplier

PostAuthorIdLike like condition %

func PostAuthorIdNotEq

func PostAuthorIdNotEq(value string) FilterApplier

PostAuthorIdNotEq returns a condition that checks if the field equals the value.

func PostAuthorIdNotIn

func PostAuthorIdNotIn(values ...interface{}) FilterApplier

PostAuthorIdNotIn not in condition

func PostAuthorIdNotLike

func PostAuthorIdNotLike(value string) FilterApplier

PostAuthorIdNotLike not like condition

func PostAuthorIdOrderBy

func PostAuthorIdOrderBy(asc bool) FilterApplier

PostAuthorIdOrderBy sorts the result in ascending order.

func PostIdBetween

func PostIdBetween(min, max int32) FilterApplier

PostIdBetween between condition.

func PostIdEq

func PostIdEq(value int32) FilterApplier

PostIdEq returns a condition that checks if the field equals the value.

func PostIdGT

func PostIdGT(value int32) FilterApplier

PostIdGT greaterThanCondition than condition.

func PostIdGTE

func PostIdGTE(value int32) FilterApplier

PostIdGTE greater than or equal condition.

func PostIdIn

func PostIdIn(values ...interface{}) FilterApplier

PostIdIn condition

func PostIdLT

func PostIdLT(value int32) FilterApplier

PostIdLT less than condition.

func PostIdLTE

func PostIdLTE(value int32) FilterApplier

PostIdLTE less than or equal condition.

func PostIdNotEq

func PostIdNotEq(value int32) FilterApplier

PostIdNotEq returns a condition that checks if the field equals the value.

func PostIdNotIn

func PostIdNotIn(values ...interface{}) FilterApplier

PostIdNotIn not in condition

func PostIdOrderBy

func PostIdOrderBy(asc bool) FilterApplier

PostIdOrderBy sorts the result in ascending order.

func SettingIdBetween

func SettingIdBetween(min, max int32) FilterApplier

SettingIdBetween between condition.

func SettingIdEq

func SettingIdEq(value int32) FilterApplier

SettingIdEq returns a condition that checks if the field equals the value.

func SettingIdGT

func SettingIdGT(value int32) FilterApplier

SettingIdGT greaterThanCondition than condition.

func SettingIdGTE

func SettingIdGTE(value int32) FilterApplier

SettingIdGTE greater than or equal condition.

func SettingIdIn

func SettingIdIn(values ...interface{}) FilterApplier

SettingIdIn condition

func SettingIdLT

func SettingIdLT(value int32) FilterApplier

SettingIdLT less than condition.

func SettingIdLTE

func SettingIdLTE(value int32) FilterApplier

SettingIdLTE less than or equal condition.

func SettingIdNotEq

func SettingIdNotEq(value int32) FilterApplier

SettingIdNotEq returns a condition that checks if the field equals the value.

func SettingIdNotIn

func SettingIdNotIn(values ...interface{}) FilterApplier

SettingIdNotIn not in condition

func SettingIdOrderBy

func SettingIdOrderBy(asc bool) FilterApplier

SettingIdOrderBy sorts the result in ascending order.

func SettingUserIdBetween

func SettingUserIdBetween(min, max string) FilterApplier

SettingUserIdBetween between condition.

func SettingUserIdEq

func SettingUserIdEq(value string) FilterApplier

SettingUserIdEq returns a condition that checks if the field equals the value.

func SettingUserIdGT

func SettingUserIdGT(value string) FilterApplier

SettingUserIdGT greaterThanCondition than condition.

func SettingUserIdGTE

func SettingUserIdGTE(value string) FilterApplier

SettingUserIdGTE greater than or equal condition.

func SettingUserIdIn

func SettingUserIdIn(values ...interface{}) FilterApplier

SettingUserIdIn condition

func SettingUserIdLT

func SettingUserIdLT(value string) FilterApplier

SettingUserIdLT less than condition.

func SettingUserIdLTE

func SettingUserIdLTE(value string) FilterApplier

SettingUserIdLTE less than or equal condition.

func SettingUserIdLike

func SettingUserIdLike(value string) FilterApplier

SettingUserIdLike like condition %

func SettingUserIdNotEq

func SettingUserIdNotEq(value string) FilterApplier

SettingUserIdNotEq returns a condition that checks if the field equals the value.

func SettingUserIdNotIn

func SettingUserIdNotIn(values ...interface{}) FilterApplier

SettingUserIdNotIn not in condition

func SettingUserIdNotLike

func SettingUserIdNotLike(value string) FilterApplier

SettingUserIdNotLike not like condition

func SettingUserIdOrderBy

func SettingUserIdOrderBy(asc bool) FilterApplier

SettingUserIdOrderBy sorts the result in ascending order.

func UserAgeBetween

func UserAgeBetween(min, max int32) FilterApplier

UserAgeBetween between condition.

func UserAgeEq

func UserAgeEq(value int32) FilterApplier

UserAgeEq returns a condition that checks if the field equals the value.

func UserAgeGT

func UserAgeGT(value int32) FilterApplier

UserAgeGT greaterThanCondition than condition.

func UserAgeGTE

func UserAgeGTE(value int32) FilterApplier

UserAgeGTE greater than or equal condition.

func UserAgeIn

func UserAgeIn(values ...interface{}) FilterApplier

UserAgeIn condition

func UserAgeLT

func UserAgeLT(value int32) FilterApplier

UserAgeLT less than condition.

func UserAgeLTE

func UserAgeLTE(value int32) FilterApplier

UserAgeLTE less than or equal condition.

func UserAgeNotEq

func UserAgeNotEq(value int32) FilterApplier

UserAgeNotEq returns a condition that checks if the field equals the value.

func UserAgeNotIn

func UserAgeNotIn(values ...interface{}) FilterApplier

UserAgeNotIn not in condition

func UserAgeOrderBy

func UserAgeOrderBy(asc bool) FilterApplier

UserAgeOrderBy sorts the result in ascending order.

func UserEmailBetween

func UserEmailBetween(min, max string) FilterApplier

UserEmailBetween between condition.

func UserEmailEq

func UserEmailEq(value string) FilterApplier

UserEmailEq returns a condition that checks if the field equals the value.

func UserEmailGT

func UserEmailGT(value string) FilterApplier

UserEmailGT greaterThanCondition than condition.

func UserEmailGTE

func UserEmailGTE(value string) FilterApplier

UserEmailGTE greater than or equal condition.

func UserEmailIn

func UserEmailIn(values ...interface{}) FilterApplier

UserEmailIn condition

func UserEmailLT

func UserEmailLT(value string) FilterApplier

UserEmailLT less than condition.

func UserEmailLTE

func UserEmailLTE(value string) FilterApplier

UserEmailLTE less than or equal condition.

func UserEmailLike

func UserEmailLike(value string) FilterApplier

UserEmailLike like condition %

func UserEmailNotEq

func UserEmailNotEq(value string) FilterApplier

UserEmailNotEq returns a condition that checks if the field equals the value.

func UserEmailNotIn

func UserEmailNotIn(values ...interface{}) FilterApplier

UserEmailNotIn not in condition

func UserEmailNotLike

func UserEmailNotLike(value string) FilterApplier

UserEmailNotLike not like condition

func UserEmailOrderBy

func UserEmailOrderBy(asc bool) FilterApplier

UserEmailOrderBy sorts the result in ascending order.

func UserIdBetween

func UserIdBetween(min, max string) FilterApplier

UserIdBetween between condition.

func UserIdEq

func UserIdEq(value string) FilterApplier

UserIdEq returns a condition that checks if the field equals the value.

func UserIdGT

func UserIdGT(value string) FilterApplier

UserIdGT greaterThanCondition than condition.

func UserIdGTE

func UserIdGTE(value string) FilterApplier

UserIdGTE greater than or equal condition.

func UserIdIn

func UserIdIn(values ...interface{}) FilterApplier

UserIdIn condition

func UserIdLT

func UserIdLT(value string) FilterApplier

UserIdLT less than condition.

func UserIdLTE

func UserIdLTE(value string) FilterApplier

UserIdLTE less than or equal condition.

func UserIdLike

func UserIdLike(value string) FilterApplier

UserIdLike like condition %

func UserIdNotEq

func UserIdNotEq(value string) FilterApplier

UserIdNotEq returns a condition that checks if the field equals the value.

func UserIdNotIn

func UserIdNotIn(values ...interface{}) FilterApplier

UserIdNotIn not in condition

func UserIdNotLike

func UserIdNotLike(value string) FilterApplier

UserIdNotLike not like condition

func UserIdOrderBy

func UserIdOrderBy(asc bool) FilterApplier

UserIdOrderBy sorts the result in ascending order.

func UserNameBetween

func UserNameBetween(min, max string) FilterApplier

UserNameBetween between condition.

func UserNameEq

func UserNameEq(value string) FilterApplier

UserNameEq returns a condition that checks if the field equals the value.

func UserNameGT

func UserNameGT(value string) FilterApplier

UserNameGT greaterThanCondition than condition.

func UserNameGTE

func UserNameGTE(value string) FilterApplier

UserNameGTE greater than or equal condition.

func UserNameIn

func UserNameIn(values ...interface{}) FilterApplier

UserNameIn condition

func UserNameLT

func UserNameLT(value string) FilterApplier

UserNameLT less than condition.

func UserNameLTE

func UserNameLTE(value string) FilterApplier

UserNameLTE less than or equal condition.

func UserNameLike

func UserNameLike(value string) FilterApplier

UserNameLike like condition %

func UserNameNotEq

func UserNameNotEq(value string) FilterApplier

UserNameNotEq returns a condition that checks if the field equals the value.

func UserNameNotIn

func UserNameNotIn(values ...interface{}) FilterApplier

UserNameNotIn not in condition

func UserNameNotLike

func UserNameNotLike(value string) FilterApplier

UserNameNotLike not like condition

func UserNameOrderBy

func UserNameOrderBy(asc bool) FilterApplier

UserNameOrderBy sorts the result in ascending order.

type GreaterThanCondition

type GreaterThanCondition struct {
	Field string
	Value interface{}
}

GreaterThanCondition greaterThanCondition than condition.

func (GreaterThanCondition) Apply

Apply applies the condition to the query.

func (GreaterThanCondition) ApplyDelete

func (c GreaterThanCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type GreaterThanOrEqualCondition

type GreaterThanOrEqualCondition struct {
	Field string
	Value interface{}
}

LessThanOrEqualCondition less than or equal condition.

func (GreaterThanOrEqualCondition) Apply

Apply applies the condition to the query.

func (GreaterThanOrEqualCondition) ApplyDelete

ApplyDelete applies the condition to the query.

type InCondition

type InCondition struct {
	Field  string
	Values []interface{}
}

InCondition represents the IN condition.

func (InCondition) Apply

func (c InCondition) Apply(query sq.SelectBuilder) sq.SelectBuilder

Apply applies the condition to the query.

func (InCondition) ApplyDelete

func (c InCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type IsNotNullCondition

type IsNotNullCondition struct {
	Field string
}

IsNotNullCondition represents the IS NOT NULL condition.

func (IsNotNullCondition) Apply

Apply applies the condition to the query.

func (IsNotNullCondition) ApplyDelete

func (c IsNotNullCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type IsNullCondition

type IsNullCondition struct {
	Field string
}

IsNullCondition represents the IS NULL condition.

func (IsNullCondition) Apply

Apply applies the condition to the query.

func (IsNullCondition) ApplyDelete

func (c IsNullCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type JoinCondition

type JoinCondition struct {
	Type  JoinType
	Table Table
	On    FilterApplier
}

func (JoinCondition) Apply

func (JoinCondition) ApplyDelete

func (c JoinCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

type JoinType

type JoinType string
const (
	LeftJoin  JoinType = "LEFT"
	InnerJoin JoinType = "INNER"
	RightJoin JoinType = "RIGHT"
)

type LessThanCondition

type LessThanCondition struct {
	Field string
	Value interface{}
}

LessThanCondition less than condition.

func (LessThanCondition) Apply

Apply applies the condition to the query.

func (LessThanCondition) ApplyDelete

func (c LessThanCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type LessThanOrEqualCondition

type LessThanOrEqualCondition struct {
	Field string
	Value interface{}
}

LessThanOrEqualCondition less than or equal condition.

func (LessThanOrEqualCondition) Apply

Apply applies the condition to the query.

func (LessThanOrEqualCondition) ApplyDelete

ApplyDelete applies the condition to the query.

type LikeCondition

type LikeCondition struct {
	Field string
	Value interface{}
}

LikeCondition like condition.

func (LikeCondition) Apply

Apply applies the condition to the query.

func (LikeCondition) ApplyDelete

func (c LikeCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type Message

type Message struct {
	Id         string `db:"id"`
	FromUserId string `db:"from_user_id"`
	ToUserId   string `db:"to_user_id"`
	FromUser   *User
	ToUser     *User
}

Message is a struct for the "messages" table.

func (*Message) ScanRow

func (t *Message) ScanRow(r *sql.Row) error

ScanRow scans a row into a Message.

func (*Message) ScanRows

func (t *Message) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the Message.

func (*Message) TableName

func (t *Message) TableName() string

TableName returns the table name.

type MessageAdvancedDeletion

type MessageAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

MessageAdvancedDeletion is an interface for advanced deletion operations.

type MessageCRUDOperations

type MessageCRUDOperations interface {
	Create(ctx context.Context, model *Message, opts ...Option) (*string, error)
	Update(ctx context.Context, id string, updateData *MessageUpdate) error
	DeleteById(ctx context.Context, id string, opts ...Option) error
	FindById(ctx context.Context, id string, opts ...Option) (*Message, error)
}

MessageCRUDOperations is an interface for managing the messages table.

type MessageFilters

type MessageFilters struct {
	Id       *string
	ToUserId *string
}

MessageFilters is a struct that holds filters for Message.

type MessagePaginationOperations

type MessagePaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*Message, *Paginator, error)
}

MessagePaginationOperations is an interface for pagination operations.

type MessageRawQueryOperations

type MessageRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

MessageRawQueryOperations is an interface for executing raw queries.

type MessageRelationLoading

type MessageRelationLoading interface {
	LoadFromUser(ctx context.Context, model *Message, builders ...*QueryBuilder) error
	LoadToUser(ctx context.Context, model *Message, builders ...*QueryBuilder) error
	LoadBatchFromUser(ctx context.Context, items []*Message, builders ...*QueryBuilder) error
	LoadBatchToUser(ctx context.Context, items []*Message, builders ...*QueryBuilder) error
}

MessageRelationLoading is an interface for loading relations.

type MessageSearchOperations

type MessageSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*Message, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*Message, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*Message, error)
}

MessageSearchOperations is an interface for searching the messages table.

type MessageStorage

MessageStorage is a struct for the "messages" table.

func NewMessageStorage

func NewMessageStorage(db *sql.DB) MessageStorage

NewMessageStorage returns a new messageStorage.

type MessageTableManager

type MessageTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

MessageTableManager is an interface for managing the messages table.

type MessageUpdate

type MessageUpdate struct {
	FromUserId *string
	ToUserId   *string
}

MessageUpdate is used to update an existing Message.

type NotEqualsCondition

type NotEqualsCondition struct {
	Field string
	Value interface{}
}

NotEqualsCondition not equals condition.

func (NotEqualsCondition) Apply

Apply applies the condition to the query.

func (NotEqualsCondition) ApplyDelete

func (c NotEqualsCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type NotInCondition

type NotInCondition struct {
	Field  string
	Values []interface{}
}

NotInCondition represents the NOT IN condition.

func (NotInCondition) Apply

Apply applies the condition to the query.

func (NotInCondition) ApplyDelete

func (c NotInCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type NotLikeCondition

type NotLikeCondition struct {
	Field string
	Value interface{}
}

NotLikeCondition not like condition.

func (NotLikeCondition) Apply

Apply applies the condition to the query.

func (NotLikeCondition) ApplyDelete

func (c NotLikeCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type Option

type Option func(*Options)

Option is a function that configures the BlogStorages.

func WithRelations

func WithRelations() Option

WithRelations sets the relations flag. This is used to determine if the relations should be created or updated.

type Options

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

Options are the options for the BlogStorages.

type OrCondition

type OrCondition struct {
	Conditions []FilterApplier
}

Or returns a condition that checks if any of the conditions are true.

func (OrCondition) Apply

func (c OrCondition) Apply(query sq.SelectBuilder) sq.SelectBuilder

Apply applies the condition to the query.

func (OrCondition) ApplyDelete

func (c OrCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

Apply applies the condition to the query.

type OrderCondition

type OrderCondition struct {
	Column string
	Asc    bool
}

OrderCondition represents the ORDER BY condition.

func (OrderCondition) Apply

Apply applies the condition to the query.

func (OrderCondition) ApplyDelete

func (c OrderCondition) ApplyDelete(query sq.DeleteBuilder) sq.DeleteBuilder

ApplyDelete applies the condition to the query.

type Pagination

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

Pagination is the pagination.

func Limit

func Limit(limit uint64) *Pagination

Limit is a helper function to create a new pagination.

func NewPagination

func NewPagination(limit, offset uint64) *Pagination

NewPagination returns a new pagination. If limit or offset are nil, then they will be omitted.

func Offset

func Offset(offset uint64) *Pagination

Offset is a helper function to create a new pagination.

type Paginator

type Paginator struct {
	TotalCount int64
	Limit      int
	Page       int
	TotalPages int
}

Pagination is the pagination.

type Post

type Post struct {
	Id       int32  `db:"id"`
	Title    string `db:"title"`
	Body     string `db:"body"`
	Author   *User
	AuthorId string `db:"author_id"`
}

Post is a struct for the "posts" table.

func (*Post) ScanRow

func (t *Post) ScanRow(r *sql.Row) error

ScanRow scans a row into a Post.

func (*Post) ScanRows

func (t *Post) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the Post.

func (*Post) TableName

func (t *Post) TableName() string

TableName returns the table name.

type PostAdvancedDeletion

type PostAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

PostAdvancedDeletion is an interface for advanced deletion operations.

type PostCRUDOperations

type PostCRUDOperations interface {
	Create(ctx context.Context, model *Post, opts ...Option) (*int32, error)
	Update(ctx context.Context, id int32, updateData *PostUpdate) error
	DeleteById(ctx context.Context, id int32, opts ...Option) error
	FindById(ctx context.Context, id int32, opts ...Option) (*Post, error)
}

PostCRUDOperations is an interface for managing the posts table.

type PostFilters

type PostFilters struct {
	Id       *int32
	AuthorId *string
}

PostFilters is a struct that holds filters for Post.

type PostPaginationOperations

type PostPaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*Post, *Paginator, error)
}

PostPaginationOperations is an interface for pagination operations.

type PostRawQueryOperations

type PostRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

PostRawQueryOperations is an interface for executing raw queries.

type PostRelationLoading

type PostRelationLoading interface {
	LoadAuthor(ctx context.Context, model *Post, builders ...*QueryBuilder) error
	LoadBatchAuthor(ctx context.Context, items []*Post, builders ...*QueryBuilder) error
}

PostRelationLoading is an interface for loading relations.

type PostSearchOperations

type PostSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*Post, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*Post, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*Post, error)
}

PostSearchOperations is an interface for searching the posts table.

type PostStorage

PostStorage is a struct for the "posts" table.

func NewPostStorage

func NewPostStorage(db *sql.DB) PostStorage

NewPostStorage returns a new postStorage.

type PostTableManager

type PostTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

PostTableManager is an interface for managing the posts table.

type PostUpdate

type PostUpdate struct {
	Title    *string
	Body     *string
	AuthorId *string
}

PostUpdate is used to update an existing Post.

type QueryBuilder

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

QueryBuilder is a query builder.

func FilterBuilder

func FilterBuilder(filterOptions ...FilterApplier) *QueryBuilder

Filter is a helper function to create a new query builder with filter options.

func LimitBuilder

func LimitBuilder(limit uint64) *QueryBuilder

Options is a helper function to create a new query builder with options.

func NewQueryBuilder

func NewQueryBuilder() *QueryBuilder

NewQueryBuilder returns a new query builder.

func OffsetBuilder

func OffsetBuilder(offset uint64) *QueryBuilder

Offset is a helper function to create a new query builder with options.

func PaginateBuilder

func PaginateBuilder(limit, offset uint64) *QueryBuilder

Paginate is a helper function to create a new query builder with options.

func SortBuilder

func SortBuilder(sortOptions ...FilterApplier) *QueryBuilder

SortBuilder is a helper function to create a new query builder with sort options.

func (*QueryBuilder) WithFilter

func (b *QueryBuilder) WithFilter(filterOptions ...FilterApplier) *QueryBuilder

WithFilterOptions sets the filter options for the query.

func (*QueryBuilder) WithOptions

func (b *QueryBuilder) WithOptions(options ...Option) *QueryBuilder

WithOptions sets the options for the query.

func (*QueryBuilder) WithPagination

func (b *QueryBuilder) WithPagination(pagination *Pagination) *QueryBuilder

WithPagination sets the pagination for the query.

func (*QueryBuilder) WithSort

func (b *QueryBuilder) WithSort(sortOptions ...FilterApplier) *QueryBuilder

WithSort sets the sort options for the query.

type QueryExecer

type QueryExecer interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

QueryExecer is an interface that can execute queries.

type Setting

type Setting struct {
	Id     int32  `db:"id"`
	Name   string `db:"name"`
	Value  string `db:"value"`
	User   *User
	UserId string `db:"user_id"`
}

Setting is a struct for the "settings" table.

func (*Setting) ScanRow

func (t *Setting) ScanRow(r *sql.Row) error

ScanRow scans a row into a Setting.

func (*Setting) ScanRows

func (t *Setting) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the Setting.

func (*Setting) TableName

func (t *Setting) TableName() string

TableName returns the table name.

type SettingAdvancedDeletion

type SettingAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

SettingAdvancedDeletion is an interface for advanced deletion operations.

type SettingCRUDOperations

type SettingCRUDOperations interface {
	Create(ctx context.Context, model *Setting, opts ...Option) (*int32, error)
	Update(ctx context.Context, id int32, updateData *SettingUpdate) error
	DeleteById(ctx context.Context, id int32, opts ...Option) error
	FindById(ctx context.Context, id int32, opts ...Option) (*Setting, error)
}

SettingCRUDOperations is an interface for managing the settings table.

type SettingFilters

type SettingFilters struct {
	Id     *int32
	UserId *string
}

SettingFilters is a struct that holds filters for Setting.

type SettingPaginationOperations

type SettingPaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*Setting, *Paginator, error)
}

SettingPaginationOperations is an interface for pagination operations.

type SettingRawQueryOperations

type SettingRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

SettingRawQueryOperations is an interface for executing raw queries.

type SettingRelationLoading

type SettingRelationLoading interface {
	LoadUser(ctx context.Context, model *Setting, builders ...*QueryBuilder) error
	LoadBatchUser(ctx context.Context, items []*Setting, builders ...*QueryBuilder) error
}

SettingRelationLoading is an interface for loading relations.

type SettingSearchOperations

type SettingSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*Setting, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*Setting, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*Setting, error)
}

SettingSearchOperations is an interface for searching the settings table.

type SettingStorage

SettingStorage is a struct for the "settings" table.

func NewSettingStorage

func NewSettingStorage(db *sql.DB) SettingStorage

NewSettingStorage returns a new settingStorage.

type SettingTableManager

type SettingTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

SettingTableManager is an interface for managing the settings table.

type SettingUpdate

type SettingUpdate struct {
	Name   *string
	Value  *string
	UserId *string
}

SettingUpdate is used to update an existing Setting.

type Table

type Table interface {
	TableName() string
}

type TxManager

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

TxManager is a transaction manager.

func NewTxManager

func NewTxManager(db *sql.DB) *TxManager

NewTxManager creates a new transaction manager.

func (*TxManager) Begin

func (m *TxManager) Begin(ctx context.Context) (context.Context, error)

Begin begins a transaction.

func (*TxManager) Commit

func (m *TxManager) Commit(ctx context.Context) error

IsTxOpen returns true if a transaction is open.

func (*TxManager) ExecFuncWithTx

func (m *TxManager) ExecFuncWithTx(ctx context.Context, f func(context.Context) error) error

ExecFuncWithTx executes a function with a transaction.

func (*TxManager) IsTxOpen

func (m *TxManager) IsTxOpen(ctx context.Context) bool

IsTxOpen returns true if a transaction is open.

func (*TxManager) Rollback

func (m *TxManager) Rollback(ctx context.Context) error

Rollback rolls back a transaction.

type User

type User struct {
	Id                   string  `db:"id"`
	Name                 string  `db:"name"`
	Age                  int32   `db:"age"`
	Email                string  `db:"email"`
	LastName             *string `db:"last_name"`
	Device               *Device
	Settings             *Setting
	Addresses            []*Address
	Posts                []*Post
	CreatedAt            time.Time                `db:"created_at"`
	UpdatedAt            *time.Time               `db:"updated_at"`
	NotificationSettings *UserNotificationSetting `db:"notification_settings"`
	Phones               UserPhonesRepeated       `db:"phones"`
	Balls                UserBallsRepeated        `db:"balls"`
	Numrs                UserNumrsRepeated        `db:"numrs"`
	Comments             UserCommentsRepeated     `db:"comments"`
}

User is a struct for the "users" table.

func (*User) ScanRow

func (t *User) ScanRow(r *sql.Row) error

ScanRow scans a row into a User.

func (*User) ScanRows

func (t *User) ScanRows(r *sql.Rows) error

ScanRows scans a single row into the User.

func (*User) TableName

func (t *User) TableName() string

TableName returns the table name.

type UserAdvancedDeletion

type UserAdvancedDeletion interface {
	DeleteMany(ctx context.Context, builders ...*QueryBuilder) error
}

UserAdvancedDeletion is an interface for advanced deletion operations.

type UserBallsRepeated

type UserBallsRepeated []int32

UserBallsRepeated is a JSON type nested in another message.

func NewBallsField

func NewBallsField(v []int32) UserBallsRepeated

NewBallsField returns a new UserBallsRepeated.

func (UserBallsRepeated) Get

func (m UserBallsRepeated) Get() []int32

Get returns the value of the field.

func (*UserBallsRepeated) Scan

func (m *UserBallsRepeated) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserBallsRepeated) String

func (m *UserBallsRepeated) String() string

func (UserBallsRepeated) Value

func (m UserBallsRepeated) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserCRUDOperations

type UserCRUDOperations interface {
	Create(ctx context.Context, model *User, opts ...Option) (*string, error)
	Update(ctx context.Context, id string, updateData *UserUpdate) error
	DeleteById(ctx context.Context, id string, opts ...Option) error
	FindById(ctx context.Context, id string, opts ...Option) (*User, error)
}

UserCRUDOperations is an interface for managing the users table.

type UserComment

type UserComment struct {
	Name string       `json:"name"`
	Meta *CommentMeta `json:"meta"`
}

Comment is a JSON type nested in another message.

func (*UserComment) Scan

func (m *UserComment) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserComment) Value

func (m *UserComment) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserCommentsRepeated

type UserCommentsRepeated []UserComment

UserCommentsRepeated is a JSON type nested in another message.

func NewCommentsField

func NewCommentsField(v []UserComment) UserCommentsRepeated

NewCommentsField returns a new UserCommentsRepeated.

func (UserCommentsRepeated) Get

Get returns the value of the field.

func (*UserCommentsRepeated) Scan

func (m *UserCommentsRepeated) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserCommentsRepeated) String

func (m *UserCommentsRepeated) String() string

func (UserCommentsRepeated) Value

func (m UserCommentsRepeated) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserFilters

type UserFilters struct {
	Id    *string
	Name  *string
	Age   *int32
	Email *string
}

UserFilters is a struct that holds filters for User.

type UserNotificationSetting

type UserNotificationSetting struct {
	RegistrationEmail bool `json:"registration_email"`
	OrderEmail        bool `json:"order_email"`
}

NotificationSetting is a JSON type nested in another message.

func (*UserNotificationSetting) Scan

func (m *UserNotificationSetting) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserNotificationSetting) Value

func (m *UserNotificationSetting) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserNumr

type UserNumr struct {
	Street string `json:"street"`
	City   string `json:"city"`
	State  int32  `json:"state"`
	Zip    int64  `json:"zip"`
}

Numr is a JSON type nested in another message.

func (*UserNumr) Scan

func (m *UserNumr) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserNumr) Value

func (m *UserNumr) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserNumrsRepeated

type UserNumrsRepeated []UserNumr

UserNumrsRepeated is a JSON type nested in another message.

func NewNumrsField

func NewNumrsField(v []UserNumr) UserNumrsRepeated

NewNumrsField returns a new UserNumrsRepeated.

func (UserNumrsRepeated) Get

func (m UserNumrsRepeated) Get() []UserNumr

Get returns the value of the field.

func (*UserNumrsRepeated) Scan

func (m *UserNumrsRepeated) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserNumrsRepeated) String

func (m *UserNumrsRepeated) String() string

func (UserNumrsRepeated) Value

func (m UserNumrsRepeated) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserPaginationOperations

type UserPaginationOperations interface {
	FindManyWithPagination(ctx context.Context, limit int, page int, builders ...*QueryBuilder) ([]*User, *Paginator, error)
}

UserPaginationOperations is an interface for pagination operations.

type UserPhonesRepeated

type UserPhonesRepeated []string

UserPhonesRepeated is a JSON type nested in another message.

func NewPhonesField

func NewPhonesField(v []string) UserPhonesRepeated

NewPhonesField returns a new UserPhonesRepeated.

func (UserPhonesRepeated) Get

func (m UserPhonesRepeated) Get() []string

Get returns the value of the field.

func (*UserPhonesRepeated) Scan

func (m *UserPhonesRepeated) Scan(src interface{}) error

Scan implements the sql.Scanner interface for JSON.

func (*UserPhonesRepeated) String

func (m *UserPhonesRepeated) String() string

func (UserPhonesRepeated) Value

func (m UserPhonesRepeated) Value() (driver.Value, error)

Value implements the driver.Valuer interface for JSON.

type UserRawQueryOperations

type UserRawQueryOperations interface {
	Query(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	QueryRows(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

UserRawQueryOperations is an interface for executing raw queries.

type UserRelationLoading

type UserRelationLoading interface {
	LoadDevice(ctx context.Context, model *User, builders ...*QueryBuilder) error
	LoadSettings(ctx context.Context, model *User, builders ...*QueryBuilder) error
	LoadAddresses(ctx context.Context, model *User, builders ...*QueryBuilder) error
	LoadPosts(ctx context.Context, model *User, builders ...*QueryBuilder) error
	LoadBatchDevice(ctx context.Context, items []*User, builders ...*QueryBuilder) error
	LoadBatchSettings(ctx context.Context, items []*User, builders ...*QueryBuilder) error
	LoadBatchAddresses(ctx context.Context, items []*User, builders ...*QueryBuilder) error
	LoadBatchPosts(ctx context.Context, items []*User, builders ...*QueryBuilder) error
}

UserRelationLoading is an interface for loading relations.

type UserSearchOperations

type UserSearchOperations interface {
	FindMany(ctx context.Context, builder ...*QueryBuilder) ([]*User, error)
	FindOne(ctx context.Context, builders ...*QueryBuilder) (*User, error)
	Count(ctx context.Context, builders ...*QueryBuilder) (int64, error)
	SelectForUpdate(ctx context.Context, builders ...*QueryBuilder) (*User, error)
}

UserSearchOperations is an interface for searching the users table.

type UserStorage

UserStorage is a struct for the "users" table.

func NewUserStorage

func NewUserStorage(db *sql.DB) UserStorage

NewUserStorage returns a new userStorage.

type UserTableManager

type UserTableManager interface {
	CreateTable(ctx context.Context) error
	DropTable(ctx context.Context) error
	TruncateTable(ctx context.Context) error
	UpgradeTable(ctx context.Context) error
}

UserTableManager is an interface for managing the users table.

type UserUpdate

type UserUpdate struct {
	Name                 *string
	Age                  *int32
	Email                *string
	LastName             *string
	CreatedAt            *time.Time
	UpdatedAt            *time.Time
	NotificationSettings *UserNotificationSetting
	Phones               *UserPhonesRepeated
	Balls                *UserBallsRepeated
	Numrs                *UserNumrsRepeated
	Comments             *UserCommentsRepeated
}

UserUpdate is used to update an existing User.

Jump to

Keyboard shortcuts

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