models

package
v0.0.0-...-3a29b05 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 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{
	Character: &schemaCharacter{
		BaseSchema: kallax.NewBaseSchema(
			"characters",
			"__character",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{
				"Player": kallax.NewForeignKey("player_id", true),
				"Map":    kallax.NewForeignKey("map_id", true),
			},
			func() kallax.Record {
				return new(Character)
			},
			true,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("player_id"),
			kallax.NewSchemaField("name"),
			kallax.NewSchemaField("job"),
			kallax.NewSchemaField("map_id"),
			kallax.NewSchemaField("level"),
			kallax.NewSchemaField("race"),
			kallax.NewSchemaField("enabled"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		PlayerFK:  kallax.NewSchemaField("player_id"),
		Name:      kallax.NewSchemaField("name"),
		Job:       kallax.NewSchemaField("job"),
		MapFK:     kallax.NewSchemaField("map_id"),
		Level:     kallax.NewSchemaField("level"),
		Race:      kallax.NewSchemaField("race"),
		Enabled:   kallax.NewSchemaField("enabled"),
	},
	Map: &schemaMap{
		BaseSchema: kallax.NewBaseSchema(
			"maps",
			"__map",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{},
			func() kallax.Record {
				return new(Map)
			},
			true,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("name"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		Name:      kallax.NewSchemaField("name"),
	},
	Player: &schemaPlayer{
		BaseSchema: kallax.NewBaseSchema(
			"players",
			"__player",
			kallax.NewSchemaField("id"),
			kallax.ForeignKeys{
				"Characters": kallax.NewForeignKey("player_id", false),
			},
			func() kallax.Record {
				return new(Player)
			},
			true,
			kallax.NewSchemaField("id"),
			kallax.NewSchemaField("created_at"),
			kallax.NewSchemaField("updated_at"),
			kallax.NewSchemaField("username"),
			kallax.NewSchemaField("email"),
			kallax.NewSchemaField("password"),
			kallax.NewSchemaField("pincode"),
			kallax.NewSchemaField("is_active"),
		),
		ID:        kallax.NewSchemaField("id"),
		CreatedAt: kallax.NewSchemaField("created_at"),
		UpdatedAt: kallax.NewSchemaField("updated_at"),
		Username:  kallax.NewSchemaField("username"),
		Email:     kallax.NewSchemaField("email"),
		Password:  kallax.NewSchemaField("password"),
		Pincode:   kallax.NewSchemaField("pincode"),
		IsActive:  kallax.NewSchemaField("is_active"),
	},
}

Functions

This section is empty.

Types

type Character

type Character struct {
	kallax.Model `table:"characters" pk:"id,autoincr"`
	kallax.Timestamps
	ID      int64
	Player  *Player `fk:"player_id,inverse"`
	Name    string  `unique:"true"`
	Job     string
	Map     *Map `fk:"map_id,inverse"`
	Level   uint16
	Race    uint16
	Enabled bool
}

func NewCharacter

func NewCharacter() (record *Character)

NewCharacter returns a new instance of Character.

func (*Character) ColumnAddress

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

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

func (*Character) GetID

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

GetID returns the primary key of the model.

func (*Character) NewRelationshipRecord

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

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

func (*Character) SetRelationship

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

SetRelationship sets the given relationship in the given field.

func (*Character) Value

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

Value returns the value of the given column.

type CharacterQuery

type CharacterQuery struct {
	*kallax.BaseQuery
}

CharacterQuery is the object used to create queries for the Character entity.

func NewCharacterQuery

func NewCharacterQuery() *CharacterQuery

NewCharacterQuery returns a new instance of CharacterQuery.

func (*CharacterQuery) BatchSize

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

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

func (*CharacterQuery) Copy

func (q *CharacterQuery) Copy() *CharacterQuery

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 (*CharacterQuery) FindByCreatedAt

func (q *CharacterQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *CharacterQuery

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

func (*CharacterQuery) FindByEnabled

func (q *CharacterQuery) FindByEnabled(v bool) *CharacterQuery

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

func (*CharacterQuery) FindByID

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

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 (*CharacterQuery) FindByJob

func (q *CharacterQuery) FindByJob(v string) *CharacterQuery

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

func (*CharacterQuery) FindByLevel

func (q *CharacterQuery) FindByLevel(cond kallax.ScalarCond, v uint16) *CharacterQuery

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

func (*CharacterQuery) FindByMap

func (q *CharacterQuery) FindByMap(v int64) *CharacterQuery

FindByMap adds a new filter to the query that will require that the foreign key of Map is equal to the passed value.

func (*CharacterQuery) FindByName

func (q *CharacterQuery) FindByName(v string) *CharacterQuery

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

func (*CharacterQuery) FindByPlayer

func (q *CharacterQuery) FindByPlayer(v int64) *CharacterQuery

FindByPlayer adds a new filter to the query that will require that the foreign key of Player is equal to the passed value.

func (*CharacterQuery) FindByRace

func (q *CharacterQuery) FindByRace(cond kallax.ScalarCond, v uint16) *CharacterQuery

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

func (*CharacterQuery) FindByUpdatedAt

func (q *CharacterQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *CharacterQuery

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

func (*CharacterQuery) Limit

func (q *CharacterQuery) Limit(n uint64) *CharacterQuery

Limit sets the max number of items to retrieve.

func (*CharacterQuery) Offset

func (q *CharacterQuery) Offset(n uint64) *CharacterQuery

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

func (*CharacterQuery) Order

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

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

func (*CharacterQuery) Select

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

Select adds columns to select in the query.

func (*CharacterQuery) SelectNot

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

SelectNot excludes columns from being selected in the query.

func (*CharacterQuery) Where

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

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

func (*CharacterQuery) WithMap

func (q *CharacterQuery) WithMap() *CharacterQuery

func (*CharacterQuery) WithPlayer

func (q *CharacterQuery) WithPlayer() *CharacterQuery

type CharacterResultSet

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

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

func NewCharacterResultSet

func NewCharacterResultSet(rs kallax.ResultSet) *CharacterResultSet

NewCharacterResultSet creates a new result set for rows of the type Character.

func (*CharacterResultSet) All

func (rs *CharacterResultSet) All() ([]*Character, error)

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

func (*CharacterResultSet) Close

func (rs *CharacterResultSet) Close() error

Close closes the result set.

func (*CharacterResultSet) Err

func (rs *CharacterResultSet) Err() error

Err returns the last error occurred.

func (*CharacterResultSet) ForEach

func (rs *CharacterResultSet) ForEach(fn func(*Character) 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 (*CharacterResultSet) Get

func (rs *CharacterResultSet) Get() (*Character, error)

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

func (*CharacterResultSet) Next

func (rs *CharacterResultSet) 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 (*CharacterResultSet) One

func (rs *CharacterResultSet) One() (*Character, error)

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

type CharacterStore

type CharacterStore struct {
	*kallax.Store
}

CharacterStore is the entity to access the records of the type Character in the database.

func NewCharacterStore

func NewCharacterStore(db *sql.DB) *CharacterStore

NewCharacterStore creates a new instance of CharacterStore using a SQL database.

func (*CharacterStore) Count

func (s *CharacterStore) Count(q *CharacterQuery) (int64, error)

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

func (*CharacterStore) Debug

func (s *CharacterStore) Debug() *CharacterStore

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

func (*CharacterStore) DebugWith

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

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

func (*CharacterStore) Delete

func (s *CharacterStore) Delete(record *Character) error

Delete removes the given record from the database.

func (*CharacterStore) Find

Find returns the set of results for the given query.

func (*CharacterStore) FindAll

func (s *CharacterStore) FindAll(q *CharacterQuery) ([]*Character, error)

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

func (*CharacterStore) FindOne

func (s *CharacterStore) FindOne(q *CharacterQuery) (*Character, error)

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

func (*CharacterStore) GenericStore

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

GenericStore returns the generic store of this store.

func (*CharacterStore) Insert

func (s *CharacterStore) Insert(record *Character) error

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

func (*CharacterStore) MustCount

func (s *CharacterStore) MustCount(q *CharacterQuery) int64

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

func (*CharacterStore) MustFind

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

func (*CharacterStore) MustFindOne

func (s *CharacterStore) MustFindOne(q *CharacterQuery) *Character

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

func (*CharacterStore) Reload

func (s *CharacterStore) Reload(record *Character) error

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

func (*CharacterStore) Save

func (s *CharacterStore) Save(record *Character) (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 (*CharacterStore) SetGenericStore

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

SetGenericStore changes the generic store of this store.

func (*CharacterStore) Transaction

func (s *CharacterStore) Transaction(callback func(*CharacterStore) 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 (*CharacterStore) Update

func (s *CharacterStore) Update(record *Character, 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.

type Map

type Map struct {
	kallax.Model `table:"maps" pk:"id,autoincr"`
	kallax.Timestamps
	ID   int64
	Name []string `unique:"true"`
}

func NewMap

func NewMap() (record *Map)

NewMap returns a new instance of Map.

func (*Map) ColumnAddress

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

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

func (*Map) GetID

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

GetID returns the primary key of the model.

func (*Map) NewRelationshipRecord

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

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

func (*Map) SetRelationship

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

SetRelationship sets the given relationship in the given field.

func (*Map) Value

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

Value returns the value of the given column.

type MapQuery

type MapQuery struct {
	*kallax.BaseQuery
}

MapQuery is the object used to create queries for the Map entity.

func NewMapQuery

func NewMapQuery() *MapQuery

NewMapQuery returns a new instance of MapQuery.

func (*MapQuery) BatchSize

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

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

func (*MapQuery) Copy

func (q *MapQuery) Copy() *MapQuery

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 (*MapQuery) FindByCreatedAt

func (q *MapQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *MapQuery

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

func (*MapQuery) FindByID

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

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 (*MapQuery) FindByName

func (q *MapQuery) FindByName(v ...string) *MapQuery

FindByName adds a new filter to the query that will require that the Name property contains all the passed values; if no passed values, it will do nothing.

func (*MapQuery) FindByUpdatedAt

func (q *MapQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *MapQuery

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

func (*MapQuery) Limit

func (q *MapQuery) Limit(n uint64) *MapQuery

Limit sets the max number of items to retrieve.

func (*MapQuery) Offset

func (q *MapQuery) Offset(n uint64) *MapQuery

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

func (*MapQuery) Order

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

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

func (*MapQuery) Select

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

Select adds columns to select in the query.

func (*MapQuery) SelectNot

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

SelectNot excludes columns from being selected in the query.

func (*MapQuery) Where

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

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

type MapResultSet

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

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

func NewMapResultSet

func NewMapResultSet(rs kallax.ResultSet) *MapResultSet

NewMapResultSet creates a new result set for rows of the type Map.

func (*MapResultSet) All

func (rs *MapResultSet) All() ([]*Map, error)

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

func (*MapResultSet) Close

func (rs *MapResultSet) Close() error

Close closes the result set.

func (*MapResultSet) Err

func (rs *MapResultSet) Err() error

Err returns the last error occurred.

func (*MapResultSet) ForEach

func (rs *MapResultSet) ForEach(fn func(*Map) 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 (*MapResultSet) Get

func (rs *MapResultSet) Get() (*Map, error)

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

func (*MapResultSet) Next

func (rs *MapResultSet) 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 (*MapResultSet) One

func (rs *MapResultSet) One() (*Map, error)

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

type MapStore

type MapStore struct {
	*kallax.Store
}

MapStore is the entity to access the records of the type Map in the database.

func NewMapStore

func NewMapStore(db *sql.DB) *MapStore

NewMapStore creates a new instance of MapStore using a SQL database.

func (*MapStore) Count

func (s *MapStore) Count(q *MapQuery) (int64, error)

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

func (*MapStore) Debug

func (s *MapStore) Debug() *MapStore

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

func (*MapStore) DebugWith

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

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

func (*MapStore) Delete

func (s *MapStore) Delete(record *Map) error

Delete removes the given record from the database.

func (*MapStore) Find

func (s *MapStore) Find(q *MapQuery) (*MapResultSet, error)

Find returns the set of results for the given query.

func (*MapStore) FindAll

func (s *MapStore) FindAll(q *MapQuery) ([]*Map, error)

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

func (*MapStore) FindOne

func (s *MapStore) FindOne(q *MapQuery) (*Map, error)

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

func (*MapStore) GenericStore

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

GenericStore returns the generic store of this store.

func (*MapStore) Insert

func (s *MapStore) Insert(record *Map) error

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

func (*MapStore) MustCount

func (s *MapStore) MustCount(q *MapQuery) int64

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

func (*MapStore) MustFind

func (s *MapStore) MustFind(q *MapQuery) *MapResultSet

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

func (*MapStore) MustFindOne

func (s *MapStore) MustFindOne(q *MapQuery) *Map

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

func (*MapStore) Reload

func (s *MapStore) Reload(record *Map) error

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

func (*MapStore) Save

func (s *MapStore) Save(record *Map) (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 (*MapStore) SetGenericStore

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

SetGenericStore changes the generic store of this store.

func (*MapStore) Transaction

func (s *MapStore) Transaction(callback func(*MapStore) 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 (*MapStore) Update

func (s *MapStore) Update(record *Map, 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.

type Player

type Player struct {
	kallax.Model `table:"players" pk:"id,autoincr"`
	kallax.Timestamps
	ID         int64
	Characters []*Character `fk:"player_id"`
	Username   string       `unique:"true"`
	Email      string
	Password   string
	Pincode    *string
	IsActive   bool
}

func NewPlayer

func NewPlayer() (record *Player)

NewPlayer returns a new instance of Player.

func (*Player) ColumnAddress

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

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

func (*Player) GetID

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

GetID returns the primary key of the model.

func (*Player) NewRelationshipRecord

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

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

func (*Player) SetRelationship

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

SetRelationship sets the given relationship in the given field.

func (*Player) Value

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

Value returns the value of the given column.

type PlayerQuery

type PlayerQuery struct {
	*kallax.BaseQuery
}

PlayerQuery is the object used to create queries for the Player entity.

func NewPlayerQuery

func NewPlayerQuery() *PlayerQuery

NewPlayerQuery returns a new instance of PlayerQuery.

func (*PlayerQuery) BatchSize

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

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

func (*PlayerQuery) Copy

func (q *PlayerQuery) Copy() *PlayerQuery

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 (*PlayerQuery) FindByCreatedAt

func (q *PlayerQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *PlayerQuery

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

func (*PlayerQuery) FindByEmail

func (q *PlayerQuery) FindByEmail(v string) *PlayerQuery

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

func (*PlayerQuery) FindByID

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

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 (*PlayerQuery) FindByIsActive

func (q *PlayerQuery) FindByIsActive(v bool) *PlayerQuery

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

func (*PlayerQuery) FindByPassword

func (q *PlayerQuery) FindByPassword(v string) *PlayerQuery

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

func (*PlayerQuery) FindByUpdatedAt

func (q *PlayerQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *PlayerQuery

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

func (*PlayerQuery) FindByUsername

func (q *PlayerQuery) FindByUsername(v string) *PlayerQuery

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

func (*PlayerQuery) Limit

func (q *PlayerQuery) Limit(n uint64) *PlayerQuery

Limit sets the max number of items to retrieve.

func (*PlayerQuery) Offset

func (q *PlayerQuery) Offset(n uint64) *PlayerQuery

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

func (*PlayerQuery) Order

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

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

func (*PlayerQuery) Select

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

Select adds columns to select in the query.

func (*PlayerQuery) SelectNot

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

SelectNot excludes columns from being selected in the query.

func (*PlayerQuery) Where

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

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

func (*PlayerQuery) WithCharacters

func (q *PlayerQuery) WithCharacters(cond kallax.Condition) *PlayerQuery

type PlayerResultSet

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

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

func NewPlayerResultSet

func NewPlayerResultSet(rs kallax.ResultSet) *PlayerResultSet

NewPlayerResultSet creates a new result set for rows of the type Player.

func (*PlayerResultSet) All

func (rs *PlayerResultSet) All() ([]*Player, error)

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

func (*PlayerResultSet) Close

func (rs *PlayerResultSet) Close() error

Close closes the result set.

func (*PlayerResultSet) Err

func (rs *PlayerResultSet) Err() error

Err returns the last error occurred.

func (*PlayerResultSet) ForEach

func (rs *PlayerResultSet) ForEach(fn func(*Player) 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 (*PlayerResultSet) Get

func (rs *PlayerResultSet) Get() (*Player, error)

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

func (*PlayerResultSet) Next

func (rs *PlayerResultSet) 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 (*PlayerResultSet) One

func (rs *PlayerResultSet) One() (*Player, error)

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

type PlayerStore

type PlayerStore struct {
	*kallax.Store
}

PlayerStore is the entity to access the records of the type Player in the database.

func NewPlayerStore

func NewPlayerStore(db *sql.DB) *PlayerStore

NewPlayerStore creates a new instance of PlayerStore using a SQL database.

func (*PlayerStore) Count

func (s *PlayerStore) Count(q *PlayerQuery) (int64, error)

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

func (*PlayerStore) Debug

func (s *PlayerStore) Debug() *PlayerStore

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

func (*PlayerStore) DebugWith

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

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

func (*PlayerStore) Delete

func (s *PlayerStore) Delete(record *Player) error

Delete removes the given record from the database.

func (*PlayerStore) Find

func (s *PlayerStore) Find(q *PlayerQuery) (*PlayerResultSet, error)

Find returns the set of results for the given query.

func (*PlayerStore) FindAll

func (s *PlayerStore) FindAll(q *PlayerQuery) ([]*Player, error)

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

func (*PlayerStore) FindOne

func (s *PlayerStore) FindOne(q *PlayerQuery) (*Player, error)

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

func (*PlayerStore) GenericStore

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

GenericStore returns the generic store of this store.

func (*PlayerStore) Insert

func (s *PlayerStore) Insert(record *Player) error

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

func (*PlayerStore) MustCount

func (s *PlayerStore) MustCount(q *PlayerQuery) int64

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

func (*PlayerStore) MustFind

func (s *PlayerStore) MustFind(q *PlayerQuery) *PlayerResultSet

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

func (*PlayerStore) MustFindOne

func (s *PlayerStore) MustFindOne(q *PlayerQuery) *Player

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

func (*PlayerStore) Reload

func (s *PlayerStore) Reload(record *Player) error

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

func (*PlayerStore) RemoveCharacters

func (s *PlayerStore) RemoveCharacters(record *Player, deleted ...*Character) error

RemoveCharacters removes the given items of the Characters field of the model. If no items are given, it removes all of them. The items will also be removed from the passed record inside this method. Note that is required that `Characters` is not empty. This method clears the the elements of Characters in a model, it does not retrieve them to know what relationships the model has.

func (*PlayerStore) Save

func (s *PlayerStore) Save(record *Player) (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 (*PlayerStore) SetGenericStore

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

SetGenericStore changes the generic store of this store.

func (*PlayerStore) Transaction

func (s *PlayerStore) Transaction(callback func(*PlayerStore) 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 (*PlayerStore) Update

func (s *PlayerStore) Update(record *Player, 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