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 ¶
- Variables
- type Character
- func (r *Character) ColumnAddress(col string) (interface{}, error)
- func (r *Character) GetID() kallax.Identifier
- func (r *Character) NewRelationshipRecord(field string) (kallax.Record, error)
- func (r *Character) SetRelationship(field string, rel interface{}) error
- func (r *Character) Value(col string) (interface{}, error)
- type CharacterQuery
- func (q *CharacterQuery) BatchSize(size uint64) *CharacterQuery
- func (q *CharacterQuery) Copy() *CharacterQuery
- func (q *CharacterQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *CharacterQuery
- func (q *CharacterQuery) FindByEnabled(v bool) *CharacterQuery
- func (q *CharacterQuery) FindByID(v ...int64) *CharacterQuery
- func (q *CharacterQuery) FindByJob(v string) *CharacterQuery
- func (q *CharacterQuery) FindByLevel(cond kallax.ScalarCond, v uint16) *CharacterQuery
- func (q *CharacterQuery) FindByMap(v int64) *CharacterQuery
- func (q *CharacterQuery) FindByName(v string) *CharacterQuery
- func (q *CharacterQuery) FindByPlayer(v int64) *CharacterQuery
- func (q *CharacterQuery) FindByRace(cond kallax.ScalarCond, v uint16) *CharacterQuery
- func (q *CharacterQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *CharacterQuery
- func (q *CharacterQuery) Limit(n uint64) *CharacterQuery
- func (q *CharacterQuery) Offset(n uint64) *CharacterQuery
- func (q *CharacterQuery) Order(cols ...kallax.ColumnOrder) *CharacterQuery
- func (q *CharacterQuery) Select(columns ...kallax.SchemaField) *CharacterQuery
- func (q *CharacterQuery) SelectNot(columns ...kallax.SchemaField) *CharacterQuery
- func (q *CharacterQuery) Where(cond kallax.Condition) *CharacterQuery
- func (q *CharacterQuery) WithMap() *CharacterQuery
- func (q *CharacterQuery) WithPlayer() *CharacterQuery
- type CharacterResultSet
- func (rs *CharacterResultSet) All() ([]*Character, error)
- func (rs *CharacterResultSet) Close() error
- func (rs *CharacterResultSet) Err() error
- func (rs *CharacterResultSet) ForEach(fn func(*Character) error) error
- func (rs *CharacterResultSet) Get() (*Character, error)
- func (rs *CharacterResultSet) Next() bool
- func (rs *CharacterResultSet) One() (*Character, error)
- type CharacterStore
- func (s *CharacterStore) Count(q *CharacterQuery) (int64, error)
- func (s *CharacterStore) Debug() *CharacterStore
- func (s *CharacterStore) DebugWith(logger kallax.LoggerFunc) *CharacterStore
- func (s *CharacterStore) Delete(record *Character) error
- func (s *CharacterStore) Find(q *CharacterQuery) (*CharacterResultSet, error)
- func (s *CharacterStore) FindAll(q *CharacterQuery) ([]*Character, error)
- func (s *CharacterStore) FindOne(q *CharacterQuery) (*Character, error)
- func (s *CharacterStore) GenericStore() *kallax.Store
- func (s *CharacterStore) Insert(record *Character) error
- func (s *CharacterStore) MustCount(q *CharacterQuery) int64
- func (s *CharacterStore) MustFind(q *CharacterQuery) *CharacterResultSet
- func (s *CharacterStore) MustFindOne(q *CharacterQuery) *Character
- func (s *CharacterStore) Reload(record *Character) error
- func (s *CharacterStore) Save(record *Character) (updated bool, err error)
- func (s *CharacterStore) SetGenericStore(store *kallax.Store)
- func (s *CharacterStore) Transaction(callback func(*CharacterStore) error) error
- func (s *CharacterStore) Update(record *Character, cols ...kallax.SchemaField) (updated int64, err error)
- type Map
- type MapQuery
- func (q *MapQuery) BatchSize(size uint64) *MapQuery
- func (q *MapQuery) Copy() *MapQuery
- func (q *MapQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *MapQuery
- func (q *MapQuery) FindByID(v ...int64) *MapQuery
- func (q *MapQuery) FindByName(v ...string) *MapQuery
- func (q *MapQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *MapQuery
- func (q *MapQuery) Limit(n uint64) *MapQuery
- func (q *MapQuery) Offset(n uint64) *MapQuery
- func (q *MapQuery) Order(cols ...kallax.ColumnOrder) *MapQuery
- func (q *MapQuery) Select(columns ...kallax.SchemaField) *MapQuery
- func (q *MapQuery) SelectNot(columns ...kallax.SchemaField) *MapQuery
- func (q *MapQuery) Where(cond kallax.Condition) *MapQuery
- type MapResultSet
- func (rs *MapResultSet) All() ([]*Map, error)
- func (rs *MapResultSet) Close() error
- func (rs *MapResultSet) Err() error
- func (rs *MapResultSet) ForEach(fn func(*Map) error) error
- func (rs *MapResultSet) Get() (*Map, error)
- func (rs *MapResultSet) Next() bool
- func (rs *MapResultSet) One() (*Map, error)
- type MapStore
- func (s *MapStore) Count(q *MapQuery) (int64, error)
- func (s *MapStore) Debug() *MapStore
- func (s *MapStore) DebugWith(logger kallax.LoggerFunc) *MapStore
- func (s *MapStore) Delete(record *Map) error
- func (s *MapStore) Find(q *MapQuery) (*MapResultSet, error)
- func (s *MapStore) FindAll(q *MapQuery) ([]*Map, error)
- func (s *MapStore) FindOne(q *MapQuery) (*Map, error)
- func (s *MapStore) GenericStore() *kallax.Store
- func (s *MapStore) Insert(record *Map) error
- func (s *MapStore) MustCount(q *MapQuery) int64
- func (s *MapStore) MustFind(q *MapQuery) *MapResultSet
- func (s *MapStore) MustFindOne(q *MapQuery) *Map
- func (s *MapStore) Reload(record *Map) error
- func (s *MapStore) Save(record *Map) (updated bool, err error)
- func (s *MapStore) SetGenericStore(store *kallax.Store)
- func (s *MapStore) Transaction(callback func(*MapStore) error) error
- func (s *MapStore) Update(record *Map, cols ...kallax.SchemaField) (updated int64, err error)
- type Player
- func (r *Player) ColumnAddress(col string) (interface{}, error)
- func (r *Player) GetID() kallax.Identifier
- func (r *Player) NewRelationshipRecord(field string) (kallax.Record, error)
- func (r *Player) SetRelationship(field string, rel interface{}) error
- func (r *Player) Value(col string) (interface{}, error)
- type PlayerQuery
- func (q *PlayerQuery) BatchSize(size uint64) *PlayerQuery
- func (q *PlayerQuery) Copy() *PlayerQuery
- func (q *PlayerQuery) FindByCreatedAt(cond kallax.ScalarCond, v time.Time) *PlayerQuery
- func (q *PlayerQuery) FindByEmail(v string) *PlayerQuery
- func (q *PlayerQuery) FindByID(v ...int64) *PlayerQuery
- func (q *PlayerQuery) FindByIsActive(v bool) *PlayerQuery
- func (q *PlayerQuery) FindByPassword(v string) *PlayerQuery
- func (q *PlayerQuery) FindByUpdatedAt(cond kallax.ScalarCond, v time.Time) *PlayerQuery
- func (q *PlayerQuery) FindByUsername(v string) *PlayerQuery
- func (q *PlayerQuery) Limit(n uint64) *PlayerQuery
- func (q *PlayerQuery) Offset(n uint64) *PlayerQuery
- func (q *PlayerQuery) Order(cols ...kallax.ColumnOrder) *PlayerQuery
- func (q *PlayerQuery) Select(columns ...kallax.SchemaField) *PlayerQuery
- func (q *PlayerQuery) SelectNot(columns ...kallax.SchemaField) *PlayerQuery
- func (q *PlayerQuery) Where(cond kallax.Condition) *PlayerQuery
- func (q *PlayerQuery) WithCharacters(cond kallax.Condition) *PlayerQuery
- type PlayerResultSet
- func (rs *PlayerResultSet) All() ([]*Player, error)
- func (rs *PlayerResultSet) Close() error
- func (rs *PlayerResultSet) Err() error
- func (rs *PlayerResultSet) ForEach(fn func(*Player) error) error
- func (rs *PlayerResultSet) Get() (*Player, error)
- func (rs *PlayerResultSet) Next() bool
- func (rs *PlayerResultSet) One() (*Player, error)
- type PlayerStore
- func (s *PlayerStore) Count(q *PlayerQuery) (int64, error)
- func (s *PlayerStore) Debug() *PlayerStore
- func (s *PlayerStore) DebugWith(logger kallax.LoggerFunc) *PlayerStore
- func (s *PlayerStore) Delete(record *Player) error
- func (s *PlayerStore) Find(q *PlayerQuery) (*PlayerResultSet, error)
- func (s *PlayerStore) FindAll(q *PlayerQuery) ([]*Player, error)
- func (s *PlayerStore) FindOne(q *PlayerQuery) (*Player, error)
- func (s *PlayerStore) GenericStore() *kallax.Store
- func (s *PlayerStore) Insert(record *Player) error
- func (s *PlayerStore) MustCount(q *PlayerQuery) int64
- func (s *PlayerStore) MustFind(q *PlayerQuery) *PlayerResultSet
- func (s *PlayerStore) MustFindOne(q *PlayerQuery) *Player
- func (s *PlayerStore) Reload(record *Player) error
- func (s *PlayerStore) RemoveCharacters(record *Player, deleted ...*Character) error
- func (s *PlayerStore) Save(record *Player) (updated bool, err error)
- func (s *PlayerStore) SetGenericStore(store *kallax.Store)
- func (s *PlayerStore) Transaction(callback func(*PlayerStore) error) error
- func (s *PlayerStore) Update(record *Player, cols ...kallax.SchemaField) (updated int64, err error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
NewRelationshipRecord returns a new record for the relatiobship in the given field.
func (*Character) SetRelationship ¶
SetRelationship sets the given relationship in the given field.
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 ¶
func (s *CharacterStore) Find(q *CharacterQuery) (*CharacterResultSet, error)
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 ¶
func (s *CharacterStore) MustFind(q *CharacterQuery) *CharacterResultSet
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 (*Map) ColumnAddress ¶
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 ¶
NewRelationshipRecord returns a new record for the relatiobship in the given field.
func (*Map) SetRelationship ¶
SetRelationship sets the given relationship in the given field.
type MapQuery ¶
type MapQuery struct {
*kallax.BaseQuery
}
MapQuery is the object used to create queries for the Map entity.
func (*MapQuery) BatchSize ¶
BatchSize sets the number of items to fetch per batch when there are 1:N relationships selected in the query.
func (*MapQuery) 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 (*MapQuery) FindByCreatedAt ¶
FindByCreatedAt adds a new filter to the query that will require that the CreatedAt property is equal to the passed value.
func (*MapQuery) FindByID ¶
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 ¶
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 ¶
FindByUpdatedAt adds a new filter to the query that will require that the UpdatedAt property is equal to the passed value.
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) 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 ¶
NewMapStore creates a new instance of MapStore using a SQL database.
func (*MapStore) Count ¶
Count returns the number of rows that would be retrieved with the given query.
func (*MapStore) Debug ¶
Debug returns a new store that will print all SQL statements to stdout using the log.Printf function.
func (*MapStore) DebugWith ¶
DebugWith returns a new store that will print all SQL statements using the given logger function.
func (*MapStore) Find ¶
func (s *MapStore) Find(q *MapQuery) (*MapResultSet, error)
Find returns the set of results for the given query.
func (*MapStore) FindOne ¶
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 ¶
Insert inserts a Map in the database. A non-persisted object is required for this operation.
func (*MapStore) MustCount ¶
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 ¶
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 ¶
Reload refreshes the Map with the data in the database and makes it writable.
func (*MapStore) Save ¶
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 ¶
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 ¶
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 (*Player) ColumnAddress ¶
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 ¶
NewRelationshipRecord returns a new record for the relatiobship in the given field.
func (*Player) SetRelationship ¶
SetRelationship sets the given relationship in the given field.
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.