Documentation ¶
Index ¶
- Constants
- func IsEmpty(v interface{}) bool
- func Mapping(t reflect.Type) (*mapping, error)
- func Scanner(v interface{}) *scanner
- type Columns
- type DeletesReferences
- type DeletesRelated
- type FetchOptions
- type FetchesRelated
- type FetchesRelatedExtra
- type ForeignEntity
- type GeneratesIdentifiers
- type Ident
- type Iter
- type ORM
- type Operation
- type PersistentMapping
- type Persister
- type Range
- type StoreOptions
- type StoresReferences
- type StoresRelated
Constants ¶
View Source
const ( StoreOptionNone = StoreOptions(0) StoreOptionStoreReferences = StoreOptions(1 << 0) StoreOptionStoreRelated = StoreOptions(1<<1) | StoreOptionStoreReferences StoreOptionDeleteReferences = StoreOptions(1 << 2) StoreOptionDeleteOrphans = StoreOptions(1<<3) | StoreOptionDeleteReferences StoreOptionCascade = StoreOptionStoreReferences | StoreOptionStoreRelated | StoreOptionDeleteReferences | StoreOptionDeleteOrphans StoreOptionReserved = StoreOptions(0xffff) // bits reserved to the `hp/db/persist` package StoreUserOption = 17 // base for user options )
View Source
const ( FetchOptionNone = FetchOptions(0) FetchOptionFetchRelated = FetchOptions(1 << 0) FetchOptionCascade = FetchOptionFetchRelated FetchOptionConcurrent = FetchOptions(1 << 1) // sub-fetches may be performed concurrently FetchOptionReserved = FetchOptions(0xffff) // bits reserved to the `hp/db/persist` package FetchUserOption = 17 // base for user options )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Columns ¶
type Columns map[string]interface{}
type DeletesReferences ¶
type DeletesReferences interface { // Delete dependent entity relationships, but not the entities DeleteReferences(interface{}, StoreOptions, godb.Context) error }
type DeletesRelated ¶
type DeletesRelated interface { // Delete dependent entities DeleteRelated(interface{}, StoreOptions, godb.Context) error }
Implemented by persisters with relationships
type FetchesRelated ¶
type FetchesRelated interface { // Fetch dependent entities FetchRelated(interface{}, FetchOptions, godb.Context) error }
Implemented by persisters with relationships
type FetchesRelatedExtra ¶
type FetchesRelatedExtra interface { // Fetch dependent entities FetchRelatedExtra(interface{}, Columns, FetchOptions, godb.Context) error }
Implemented by persisters with relationships that support extra properties (e.g., for foreign keys)
type ForeignEntity ¶
type ForeignEntity interface {
// Obtain the foreign key that identifies this entity
ForeignKey() interface{}
}
Implemented by foreign entities
type GeneratesIdentifiers ¶
type GeneratesIdentifiers interface { // Determine if this entity is transient or not. Within the scope of a single store operation, this method // will only be called by the ORM before calling GenerateId (if necessary) and setting the generated identifier. IsTransient(interface{}, godb.Context) (bool, error) // Generate and set identifiers as necessary for the provided entity GenerateId(interface{}, godb.Context) (interface{}, error) }
Implemented by persisters that explicitly generate identifiers
type Ident ¶
type Ident interface {
// Produce a new, unique identifier
New() interface{}
}
Identifier type
type ORM ¶
type ORM interface { Context(godb.Context) godb.Context DefaultContext() godb.Context StoreEntity(Persister, interface{}, StoreOptions, godb.Context) error CountEntities(Persister, godb.Context, string, ...interface{}) (int, error) FetchEntity(Persister, interface{}, FetchOptions, godb.Context, string, ...interface{}) error FetchEntities(Persister, interface{}, FetchOptions, godb.Context, string, ...interface{}) error IterEntities(Persister, reflect.Type, FetchOptions, godb.Context, string, ...interface{}) (*iter, error) DeleteEntity(Persister, interface{}, StoreOptions, godb.Context) error StoreRelated(Persister, interface{}, StoreOptions, godb.Context) error FetchRelated(Persister, interface{}, Columns, FetchOptions, godb.Context) error StoreReferences(Persister, interface{}, StoreOptions, godb.Context) error DeleteRelated(Persister, interface{}, StoreOptions, godb.Context) error DeleteReferences(Persister, interface{}, StoreOptions, godb.Context) error }
An ORM
type PersistentMapping ¶
type PersistentMapping interface { // Obtain the entity's primary key column names. PrimaryKeys() []string // Obtain the entity's column names. Columns() []string // Obtain the persistent identifier for an entity. If this identifier is nil or empty the entity is considered transient. PersistentId(interface{}) interface{} // Set the persistent identifier for an entity, e.g., when inserting. SetPersistentId(interface{}, interface{}) error // Generate a new persistent identifier. NewPersistentId(interface{}) interface{} // Obtain a relational column-to-value mapping of this entity's values, EXCLUDING the primary key, which is the persistent id. PersistentValues(interface{}) (Columns, error) // Obtain scanning destinaions for the provided ordered relational columns INCLUDING the primary key. This weird interface is an artifact of sql.Rows.Scan(). ValueDestinations(interface{}, []string) ([]interface{}, Columns, error) }
Implemented by entities that define explicit mappings
type Persister ¶
type Persister interface { // Obtain the persistent table name. Table() string }
Implemented by persisters
type StoresReferences ¶
type StoresReferences interface { // Persist relationships for dependent entities, but not the entities StoreReferences(interface{}, StoreOptions, godb.Context) error }
type StoresRelated ¶
type StoresRelated interface { // Persist dependent entities StoreRelated(interface{}, StoreOptions, godb.Context) error }
Implemented by persisters with relationships
Click to show internal directories.
Click to hide internal directories.