models

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

IMPORTANT! This is auto generated code by https://github.com/src-d/go-kallax Please, do not touch the code below, and if you do, do it under your own risk. Take into account that all the code you write here will be completely erased from earth the next time you generate the kallax models.

Index

Constants

This section is empty.

Variables

View Source
var Schema = &schema{
	StatsPeriod: &schemaStatsPeriod{
		BaseSchema: kallax.NewBaseSchema(
			"server_stats_periods",
			"__statsperiod",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{},
			func() kallax.Record {
				return new(StatsPeriod)
			},
			true,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("started"),
			kallax.NewSchemaField("duration"),
			kallax.NewSchemaField("guild_id"),
			kallax.NewSchemaField("user_id"),
			kallax.NewSchemaField("channel_id"),
			kallax.NewSchemaField("count"),
		),
		ID:        kallax.NewSchemaField("id"),
		Started:   kallax.NewSchemaField("started"),
		Duration:  kallax.NewSchemaField("duration"),
		GuildID:   kallax.NewSchemaField("guild_id"),
		UserID:    kallax.NewSchemaField("user_id"),
		ChannelID: kallax.NewSchemaField("channel_id"),
		Count:     kallax.NewSchemaField("count"),
	},
}

Functions

This section is empty.

Types

type StatsPeriod

type StatsPeriod struct {
	kallax.Model `table:"server_stats_periods" pk:"id,autoincr"`

	Started  time.Time
	Duration time.Duration

	ID        int64
	GuildID   int64
	UserID    int64
	ChannelID int64
	Count     int64
}

func NewStatsPeriod

func NewStatsPeriod() (record *StatsPeriod)

NewStatsPeriod returns a new instance of StatsPeriod.

func (*StatsPeriod) ColumnAddress

func (r *StatsPeriod) ColumnAddress(col string) (interface{}, error)

ColumnAddress returns the pointer to the value of the given column.

func (*StatsPeriod) GetID

func (r *StatsPeriod) GetID() kallax.Identifier

GetID returns the primary key of the model.

func (*StatsPeriod) NewRelationshipRecord

func (r *StatsPeriod) NewRelationshipRecord(field string) (kallax.Record, error)

NewRelationshipRecord returns a new record for the relatiobship in the given field.

func (*StatsPeriod) SetRelationship

func (r *StatsPeriod) SetRelationship(field string, rel interface{}) error

SetRelationship sets the given relationship in the given field.

func (*StatsPeriod) Value

func (r *StatsPeriod) Value(col string) (interface{}, error)

Value returns the value of the given column.

type StatsPeriodQuery

type StatsPeriodQuery struct {
	*kallax.BaseQuery
}

StatsPeriodQuery is the object used to create queries for the StatsPeriod entity.

func NewStatsPeriodQuery

func NewStatsPeriodQuery() *StatsPeriodQuery

NewStatsPeriodQuery returns a new instance of StatsPeriodQuery.

func (*StatsPeriodQuery) BatchSize

func (q *StatsPeriodQuery) BatchSize(size uint64) *StatsPeriodQuery

BatchSize sets the number of items to fetch per batch when there are 1:N relationships selected in the query.

func (*StatsPeriodQuery) Copy

Copy returns a new identical copy of the query. Remember queries are mutable so make a copy any time you need to reuse them.

func (*StatsPeriodQuery) FindByChannelID

func (q *StatsPeriodQuery) FindByChannelID(cond kallax.ScalarCond, v int64) *StatsPeriodQuery

FindByChannelID adds a new filter to the query that will require that the ChannelID property is equal to the passed value.

func (*StatsPeriodQuery) FindByCount

func (q *StatsPeriodQuery) FindByCount(cond kallax.ScalarCond, v int64) *StatsPeriodQuery

FindByCount adds a new filter to the query that will require that the Count property is equal to the passed value.

func (*StatsPeriodQuery) FindByDuration

func (q *StatsPeriodQuery) FindByDuration(cond kallax.ScalarCond, v time.Duration) *StatsPeriodQuery

FindByDuration adds a new filter to the query that will require that the Duration property is equal to the passed value.

func (*StatsPeriodQuery) FindByGuildID

func (q *StatsPeriodQuery) FindByGuildID(cond kallax.ScalarCond, v int64) *StatsPeriodQuery

FindByGuildID adds a new filter to the query that will require that the GuildID property is equal to the passed value.

func (*StatsPeriodQuery) FindByID

func (q *StatsPeriodQuery) FindByID(v ...int64) *StatsPeriodQuery

FindByID adds a new filter to the query that will require that the ID property is equal to one of the passed values; if no passed values, it will do nothing.

func (*StatsPeriodQuery) FindByStarted

func (q *StatsPeriodQuery) FindByStarted(cond kallax.ScalarCond, v time.Time) *StatsPeriodQuery

FindByStarted adds a new filter to the query that will require that the Started property is equal to the passed value.

func (*StatsPeriodQuery) FindByUserID

func (q *StatsPeriodQuery) FindByUserID(cond kallax.ScalarCond, v int64) *StatsPeriodQuery

FindByUserID adds a new filter to the query that will require that the UserID property is equal to the passed value.

func (*StatsPeriodQuery) Limit

Limit sets the max number of items to retrieve.

func (*StatsPeriodQuery) Offset

Offset sets the number of items to skip from the result set of items.

func (*StatsPeriodQuery) Order

func (q *StatsPeriodQuery) Order(cols ...kallax.ColumnOrder) *StatsPeriodQuery

Order adds order clauses to the query for the given columns.

func (*StatsPeriodQuery) Select

func (q *StatsPeriodQuery) Select(columns ...kallax.SchemaField) *StatsPeriodQuery

Select adds columns to select in the query.

func (*StatsPeriodQuery) SelectNot

func (q *StatsPeriodQuery) SelectNot(columns ...kallax.SchemaField) *StatsPeriodQuery

SelectNot excludes columns from being selected in the query.

func (*StatsPeriodQuery) Where

func (q *StatsPeriodQuery) Where(cond kallax.Condition) *StatsPeriodQuery

Where adds a condition to the query. All conditions added are concatenated using a logical AND.

type StatsPeriodResultSet

type StatsPeriodResultSet struct {
	ResultSet kallax.ResultSet
	// contains filtered or unexported fields
}

StatsPeriodResultSet is the set of results returned by a query to the database.

func NewStatsPeriodResultSet

func NewStatsPeriodResultSet(rs kallax.ResultSet) *StatsPeriodResultSet

NewStatsPeriodResultSet creates a new result set for rows of the type StatsPeriod.

func (*StatsPeriodResultSet) All

func (rs *StatsPeriodResultSet) All() ([]*StatsPeriod, error)

All returns all records on the result set and closes the result set.

func (*StatsPeriodResultSet) Close

func (rs *StatsPeriodResultSet) Close() error

Close closes the result set.

func (*StatsPeriodResultSet) Err

func (rs *StatsPeriodResultSet) Err() error

Err returns the last error occurred.

func (*StatsPeriodResultSet) ForEach

func (rs *StatsPeriodResultSet) ForEach(fn func(*StatsPeriod) error) error

ForEach iterates over the complete result set passing every record found to the given callback. It is possible to stop the iteration by returning `kallax.ErrStop` in the callback. Result set is always closed at the end.

func (*StatsPeriodResultSet) Get

func (rs *StatsPeriodResultSet) Get() (*StatsPeriod, error)

Get retrieves the last fetched item from the result set and the last error.

func (*StatsPeriodResultSet) Next

func (rs *StatsPeriodResultSet) Next() bool

Next fetches the next item in the result set and returns true if there is a next item. The result set is closed automatically when there are no more items.

func (*StatsPeriodResultSet) One

func (rs *StatsPeriodResultSet) One() (*StatsPeriod, error)

One returns the first record on the result set and closes the result set.

type StatsPeriodStore

type StatsPeriodStore struct {
	*kallax.Store
}

StatsPeriodStore is the entity to access the records of the type StatsPeriod in the database.

func NewStatsPeriodStore

func NewStatsPeriodStore(db *sql.DB) *StatsPeriodStore

NewStatsPeriodStore creates a new instance of StatsPeriodStore using a SQL database.

func (*StatsPeriodStore) Count

func (s *StatsPeriodStore) Count(q *StatsPeriodQuery) (int64, error)

Count returns the number of rows that would be retrieved with the given query.

func (*StatsPeriodStore) Debug

func (s *StatsPeriodStore) Debug() *StatsPeriodStore

Debug returns a new store that will print all SQL statements to stdout using the log.Printf function.

func (*StatsPeriodStore) DebugWith

func (s *StatsPeriodStore) DebugWith(logger kallax.LoggerFunc) *StatsPeriodStore

DebugWith returns a new store that will print all SQL statements using the given logger function.

func (*StatsPeriodStore) Delete

func (s *StatsPeriodStore) Delete(record *StatsPeriod) error

Delete removes the given record from the database.

func (*StatsPeriodStore) Find

Find returns the set of results for the given query.

func (*StatsPeriodStore) FindAll

func (s *StatsPeriodStore) FindAll(q *StatsPeriodQuery) ([]*StatsPeriod, error)

FindAll returns a list of all the rows returned by the given query.

func (*StatsPeriodStore) FindOne

FindOne returns the first row returned by the given query. `ErrNotFound` is returned if there are no results.

func (*StatsPeriodStore) GenericStore

func (s *StatsPeriodStore) GenericStore() *kallax.Store

GenericStore returns the generic store of this store.

func (*StatsPeriodStore) Insert

func (s *StatsPeriodStore) Insert(record *StatsPeriod) error

Insert inserts a StatsPeriod in the database. A non-persisted object is required for this operation.

func (*StatsPeriodStore) MustCount

func (s *StatsPeriodStore) MustCount(q *StatsPeriodQuery) int64

MustCount returns the number of rows that would be retrieved with the given query, but panics if there is an error.

func (*StatsPeriodStore) MustFind

MustFind returns the set of results for the given query, but panics if there is any error.

func (*StatsPeriodStore) MustFindOne

func (s *StatsPeriodStore) MustFindOne(q *StatsPeriodQuery) *StatsPeriod

MustFindOne returns the first row retrieved by the given query. It panics if there is an error or if there are no rows.

func (*StatsPeriodStore) Reload

func (s *StatsPeriodStore) Reload(record *StatsPeriod) error

Reload refreshes the StatsPeriod with the data in the database and makes it writable.

func (*StatsPeriodStore) Save

func (s *StatsPeriodStore) Save(record *StatsPeriod) (updated bool, err error)

Save inserts the object if the record is not persisted, otherwise it updates it. Same rules of Update and Insert apply depending on the case.

func (*StatsPeriodStore) SetGenericStore

func (s *StatsPeriodStore) SetGenericStore(store *kallax.Store)

SetGenericStore changes the generic store of this store.

func (*StatsPeriodStore) Transaction

func (s *StatsPeriodStore) Transaction(callback func(*StatsPeriodStore) error) error

Transaction executes the given callback in a transaction and rollbacks if an error is returned. The transaction is only open in the store passed as a parameter to the callback.

func (*StatsPeriodStore) Update

func (s *StatsPeriodStore) Update(record *StatsPeriod, cols ...kallax.SchemaField) (updated int64, err error)

Update updates the given record on the database. If the columns are given, only these columns will be updated. Otherwise all of them will be. Be very careful with this, as you will have a potentially different object in memory but not on the database. Only writable records can be updated. Writable objects are those that have been just inserted or retrieved using a query with no custom select fields.

Jump to

Keyboard shortcuts

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