Documentation
¶
Index ¶
- func SnakeToUpperCamel(raw string) string
- type AliasObjValMap
- type AliasedObjects
- type ColumnAlias
- type ColumnAliasField
- type CompositeKey
- type CompositeObject
- type DefaultAttributes
- type DefaultCompositeDBObject
- func (bo *DefaultCompositeDBObject) GetColumnNames() []string
- func (bo DefaultCompositeDBObject) IsSaved() bool
- func (bo *DefaultCompositeDBObject) PostInsertActions() (err error)
- func (bo *DefaultCompositeDBObject) PreInsertActions() (err error)
- func (bo *DefaultCompositeDBObject) SetColumnNames(columns []string)
- func (bo *DefaultCompositeDBObject) SetSaved(saved bool)
- type DefaultDBObject
- func (bo DefaultDBObject) GetID() ID
- func (bo DefaultDBObject) GetIDColumn() string
- func (bo DefaultDBObject) IDIsSet() bool
- func (bo *DefaultDBObject) IsSaved() bool
- func (bo *DefaultDBObject) NewID() ID
- func (bo *DefaultDBObject) PostInsertActions() (err error)
- func (bo *DefaultDBObject) PreInsertActions() (err error)
- func (bo *DefaultDBObject) SetID(id ID) error
- func (bo *DefaultDBObject) SetSaved(saved bool)
- type DefaultDiffable
- type Diffable
- type ID
- type IDAttribute
- type IDObject
- type IntID
- type JSONExportedDefaultAttributes
- type Object
- type QueryResult
- type QueryResults
- type Relationship
- type Relationshipable
- type SimpleCompositeKey
- type UnexportedDefaultAttributes
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SnakeToUpperCamel ¶
SnakeToUpperCamel converts a string in snake_case to a string in UpperCamelCase.
Types ¶
type AliasObjValMap ¶
type AliasedObjects ¶
type AliasedObjects struct {
// contains filtered or unexported fields
}
func NewAliasedObjects ¶
func NewAliasedObjects(objects ...Object) (*AliasedObjects, error)
func NewAliasedObjectsFromExisting ¶
func NewAliasedObjectsFromExisting( aliasedObjectMap map[string]Object, ) (*AliasedObjects, error)
NewAliasedObjectsFromExisting takes an oldfashion map-style aliased object and creates a new AliasedObjects struct.
func (AliasedObjects) ObjectAlias ¶
func (self AliasedObjects) ObjectAlias( object Object, ) (string, error)
func (AliasedObjects) ObjectIsAliased ¶
func (self AliasedObjects) ObjectIsAliased(object Object) bool
func (AliasedObjects) TableForAlias ¶
func (self AliasedObjects) TableForAlias(alias string) string
func (AliasedObjects) TypeForAlias ¶
func (self AliasedObjects) TypeForAlias(alias string) *reflect.Type
type ColumnAlias ¶
type ColumnAlias struct { TableAlias, ColumnName string }
func ColumnAliasFromString ¶
func ColumnAliasFromString(rawColumn string) (*ColumnAlias, bool)
func (ColumnAlias) String ¶
func (self ColumnAlias) String() string
type ColumnAliasField ¶
type ColumnAliasField struct { ColumnAlias FieldName string }
type CompositeKey ¶
CompositeKey is a composite key made up of one or more columns.
type CompositeObject ¶
type CompositeObject interface { Object CompositeKey }
CompositeObject is an object which has an CompositeAttribute.
type DefaultAttributes ¶
type DefaultAttributes interface { Update() Init() }
DefaultAttributes are a set of default attributes for an object.
type DefaultCompositeDBObject ¶
type DefaultCompositeDBObject struct { JSONExportedDefaultAttributes DefaultDiffable // contains filtered or unexported fields }
DefaultCompositeDBObject is a basic object with standard implementations.
func (*DefaultCompositeDBObject) GetColumnNames ¶
func (bo *DefaultCompositeDBObject) GetColumnNames() []string
GetColumnNames retrieves the database column names for the composite key.
func (DefaultCompositeDBObject) IsSaved ¶
func (bo DefaultCompositeDBObject) IsSaved() bool
IsSaved will return a bool encapsulating wether the object has been saved or not.
func (*DefaultCompositeDBObject) PostInsertActions ¶
func (bo *DefaultCompositeDBObject) PostInsertActions() (err error)
PostInsertActions is a NOOP for default UUID object.
func (*DefaultCompositeDBObject) PreInsertActions ¶
func (bo *DefaultCompositeDBObject) PreInsertActions() (err error)
PreInsertActions will initialize the default attributes.
func (*DefaultCompositeDBObject) SetColumnNames ¶
func (bo *DefaultCompositeDBObject) SetColumnNames(columns []string)
SetColumnNames retrieves the database column names for the composite key.
func (*DefaultCompositeDBObject) SetSaved ¶
func (bo *DefaultCompositeDBObject) SetSaved(saved bool)
SetSaved modifies the saved status of the object.
type DefaultDBObject ¶
type DefaultDBObject struct { JSONExportedDefaultAttributes DefaultDiffable ID *IntID `json:"id" db:"id"` // contains filtered or unexported fields }
DefaultDBObject is a basic object with standard implementations.
func (DefaultDBObject) GetIDColumn ¶
func (bo DefaultDBObject) GetIDColumn() string
GetIDColumn returns the column the ID lives in.
func (DefaultDBObject) IDIsSet ¶
func (bo DefaultDBObject) IDIsSet() bool
IDIsSet will check if the ID is set and return true if it has been set.
func (*DefaultDBObject) IsSaved ¶
func (bo *DefaultDBObject) IsSaved() bool
IsSaved will return a bool encapsulating wether the object has been saved or not.
func (*DefaultDBObject) NewID ¶
func (bo *DefaultDBObject) NewID() ID
NewID returns nil because it can't generate a new ID without seeing existing IDs.
func (*DefaultDBObject) PostInsertActions ¶
func (bo *DefaultDBObject) PostInsertActions() (err error)
PostInsertActions is a NOOP for default UUID object.
func (*DefaultDBObject) PreInsertActions ¶
func (bo *DefaultDBObject) PreInsertActions() (err error)
PreInsertActions will initialize the default attributes.
func (*DefaultDBObject) SetSaved ¶
func (bo *DefaultDBObject) SetSaved(saved bool)
SetSaved sets the saved status for the object.
type DefaultDiffable ¶
type DefaultDiffable struct {
// contains filtered or unexported fields
}
DefaultDiffable is the basic standard implementation of a diffable.
func (DefaultDiffable) GetLastSavedValue ¶
func (dd DefaultDiffable) GetLastSavedValue(name string) interface{}
GetLastSavedValue will get a given value from the last values map.
func (*DefaultDiffable) SetLastSavedValue ¶
func (dd *DefaultDiffable) SetLastSavedValue(name string, val interface{})
SetLastSavedValue will set a given value in the last values map.
type Diffable ¶
type Diffable interface { GetLastSavedValue(string) interface{} SetLastSavedValue(string, interface{}) }
Diffable allows something to track changes to the item before saving to optimize inserts.
type ID ¶
ID is a type of attribute for an object that implements some conversion methods. Required conversions:
- From/To database
- To string
- From/To JSON
type IDAttribute ¶
type IDAttribute interface { SetID(ID) error GetID() ID IDIsSet() bool NewID() ID GetIDColumn() string }
IDAttribute is an interface for doing common ID operations.
type IDObject ¶
type IDObject interface { Object IDAttribute }
IDObject is an object which has an IDAttribute.
type IntID ¶
type IntID struct {
ID int64
}
IntID is an object with an integer ID.
func (IntID) MarshalJSON ¶
MarshalJSON returns the JSON representation.
func (IntID) UnmarshalJSON ¶
UnmarshalJSON returns the JSON representation.
type JSONExportedDefaultAttributes ¶
type JSONExportedDefaultAttributes struct { Created types.Timestamp `db:"created" json:"created,omitempty"` Updated types.Timestamp `db:"updated" json:"updated,omitempty"` }
JSONExportedDefaultAttributes is a set of sensible default attributes that are serialized into json.
func (*JSONExportedDefaultAttributes) Init ¶
func (j *JSONExportedDefaultAttributes) Init()
Init will initialize the created & updated time.
func (*JSONExportedDefaultAttributes) Update ¶
func (j *JSONExportedDefaultAttributes) Update()
Update will initialize the updated time.
type Object ¶
type Object interface { GetTableName() string IsSaved() bool SetSaved(bool) PreInsertActions() error PostInsertActions() error }
Object is a database object able to be written to the DB.
type QueryResult ¶
type QueryResult struct {
// contains filtered or unexported fields
}
QueryResult is a set of all the results from a query in objects.
func NewQueryResult ¶
func NewQueryResult( rows *sqlx.Rows, aliasedObjects *AliasedObjects, columnAliasFields []ColumnAliasField, ) (*QueryResult, error)
func (QueryResult) WriteTo ¶
func (self QueryResult) WriteTo(objects ...interface{}) error
type QueryResults ¶
type QueryResults struct {
// contains filtered or unexported fields
}
func NewQueryResults ¶
func NewQueryResults( tx *sqlx.Tx, rows *sqlx.Rows, aliasedObjects *AliasedObjects, typeBSFieldMap map[reflect.Type]*refl.GroupedFieldsWithBS, ) *QueryResults
func (*QueryResults) Err ¶
func (self *QueryResults) Err() error
func (*QueryResults) GetResult ¶
func (self *QueryResults) GetResult() *QueryResult
func (*QueryResults) Next ¶
func (self *QueryResults) Next() bool
func (*QueryResults) WriteAllTo ¶
func (self *QueryResults) WriteAllTo( objectSlices ...interface{}, ) (retErr error)
type Relationship ¶
Relationship is a representation of how two objects join together.
func (Relationship) Invert ¶
func (self Relationship) Invert() *Relationship
Invert takes the relationship and swaps the self with the target. This essentially has the effect of changing:
foo.bar=baz.fizz
Into:
baz.fizz=foo.bar
func (Relationship) SelfTable ¶
func (self Relationship) SelfTable() string
func (Relationship) TargetTable ¶
func (self Relationship) TargetTable() string
type Relationshipable ¶
type Relationshipable interface {
Relationships() []Relationship
}
Relationshipable is a type that has at least on relationship.
type SimpleCompositeKey ¶
type SimpleCompositeKey struct {
// contains filtered or unexported fields
}
SimpleCompositeKey is a simple composite key implementation.
func (SimpleCompositeKey) GetColumnNames ¶
func (sck SimpleCompositeKey) GetColumnNames() []string
GetColumnNames retrieves the database column names for the composite key.
func (*SimpleCompositeKey) SetColumnNames ¶
func (sck *SimpleCompositeKey) SetColumnNames(columns []string)
SetColumnNames retrieves the database column names for the composite key.
type UnexportedDefaultAttributes ¶
type UnexportedDefaultAttributes struct { Created types.Timestamp `db:"created" json:"-"` Updated types.Timestamp `db:"updated" json:"-"` }
UnexportedDefaultAttributes is a set of sensible default attributes for an object that are not exported when serialized.
func (*UnexportedDefaultAttributes) Init ¶
func (j *UnexportedDefaultAttributes) Init()
Init will initialize the created time and updated time.
func (*UnexportedDefaultAttributes) Update ¶
func (j *UnexportedDefaultAttributes) Update()
Update will update the updated time.
Source Files
¶
- aliased_objects.go
- column_alias.go
- composite_key.go
- composite_object.go
- default_attributes.go
- default_composite_object.go
- default_db_object.go
- diffable.go
- id.go
- id_attribute.go
- id_object.go
- int_id.go
- json_exported_default_attributes.go
- object.go
- query_result.go
- query_results.go
- relationshipable.go
- tools.go
- unexported_default_attributes.go