Documentation ¶
Overview ¶
Package models provides shared model definitions.
Index ¶
- Constants
- Variables
- func NotNullConstraint(err error) bool
- func UniqueConstraint(err error) bool
- func Update(ctx context.Context, conn *pgx.Conn, tableName string, id ID, colName string, ...) error
- type Base
- type ID
- type Kind
- type Meta
- type Role
- type Status
- type WithID
- type WithOrg
- type WithReposity
- type WithUser
Constants ¶
const ( KindNone = Kind(0) KindOrg = Kind(1) KindUser = Kind(2) KindRepository = Kind(3) )
Variables ¶
var ErrConflict error = errors.New("row insertion conflict")
ErrConflict describes a duplicate row insertion.
var ErrDisallowedValue error = errors.New("value disallowed in this context")
ErrDisallowedValue signals a value of the right type, just not allowed.
var ErrModelMigrate error = errors.New("schema version error; cannot migrate model")
ErrModelMigrate signals a model could not be migrated to a different version.
var ErrNotFound error = errors.New("related model not found")
ErrNotFound describes an unfound model.
var ErrRelatedOrg error = errors.New("related org is missing or not Active")
ErrRelatedOrg signals that an org is missing or not Active.
var ErrRelatedUser error = errors.New("related user is missing, not Active, or is in a different org")
ErrRelatedUser signals that a user is missing, not Active, or is in a different org.
var ErrRole error = errors.New("malformed or disallowed role")
ErrRole signals a problem with a role field.
var ErrRowsAffected error = errors.New("db RowsAffected was not correct")
ErrRowsAffected describes an incorrect number of rows changed from a db mutation.
var ErrStatus error = errors.New("malformed or disallowed status")
ErrStatus signals a problem with a status field.
var ErrUnsafeString error = errors.New("string deemed unsafe")
ErrUnsafeString signals bad string input.
Functions ¶
func NotNullConstraint ¶
NotNullConstraint will try to match the db not-null constraint violation.
func UniqueConstraint ¶
UniqueConstraint will try to match the db unique constraint violation.
Types ¶
type Meta ¶
type Meta struct { Ctime int64 `json:"ctime"` Mtime int64 `json:"mtime"` Role Role `json:"role"` SchemaVersion int64 `json:"schema_version"` Signature uuid.UUID `json:"signature"` Status Status `json:"status"` }
Meta models metadata common to all models.
Ctime and Mtime are set in db by a trigger as unixtime. Signature is set in db by a trigger as a UUID -> Text conversion.
Default initialization will have Role as RoleNormal. Status as StatusUnconfirmed, which is intended.
type Role ¶
type Role int64
Role describes the context of a model row. Role is an int64 when stored in the db.
func (*Role) UnmarshalJSON ¶
type Status ¶
type Status int64
Status describes the active state of a model row. Status is an int64 when stored in the db.
func (*Status) UnmarshalJSON ¶
type WithID ¶
type WithID interface {
GetID() ID
}
WithID indicates a model has a retrievable model ID.
type WithOrg ¶
type WithOrg interface {
GetOrg() ID
}
WithOrg indicates a model has a retrievable Org ID.
type WithReposity ¶
type WithReposity interface {
GetRepository() ID
}
WithRepository indicates a models has a retrievable RepositoryID.