Documentation ¶
Overview ¶
Package object implements the database.Model interface for the Variable entity.
Index ¶
- func InitEvent(dis event.Dispatcher) queue.InitFunc
- func LoadRelations(loaders *database.Loaders, vv ...*Variable) error
- func Model(vv []*Variable) func(int) database.Model
- type Event
- type Form
- type Store
- func (s *Store) All(opts ...query.Option) ([]*Variable, error)
- func (s *Store) Bind(mm ...database.Model)
- func (s *Store) Chown(from, to int64) error
- func (s *Store) Create(authorId int64, key, val string) (*Variable, error)
- func (s *Store) Delete(ids ...int64) error
- func (s *Store) Get(opts ...query.Option) (*Variable, error)
- func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Variable, database.Paginator, error)
- func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *Store) New() *Variable
- func (s *Store) Paginate(page int64, opts ...query.Option) (database.Paginator, error)
- type Variable
- func (v *Variable) Bind(mm ...database.Model)
- func (v *Variable) Endpoint(uri ...string) string
- func (v *Variable) IsZero() bool
- func (v *Variable) JSON(addr string) map[string]interface{}
- func (v *Variable) Primary() (string, int64)
- func (v *Variable) SetPrimary(i int64)
- func (v *Variable) Values() map[string]interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadRelations ¶
LoadRelations loads all of the available relations for the given Variable models using the given loaders available.
Types ¶
type Form ¶
type Form struct { namespace.Resource Variables *Store `schema:"-"` Key string `schema:"key" json:"key"` Value string `schema:"value" json:"value"` }
Form is the type that represents input data for creating a new variable.
func (Form) Fields ¶
Fields returns a map of fields for the current Form. This map will contain the Namespace, Key, and Value fields of the current Form.
func (Form) Validate ¶
Validate will bind a Namespace to the Form's Store, if the Namespace field is present. The presence of the Key field is then checked, followed by a validitity check for that Key (is only letters, and numbers with dashes). A uniqueness check is done on the Name for the current Namespace. Another check is also done to check the presence of the Value field.
type Store ¶
type Store struct { database.Store // User is the bound user.User model. If not nil this will bind the // user.User model to any Variable models that are created. If not nil this // will append a WHERE clause on the user_id column for all SELECT queries // performed. User *user.User // Namespace is the bound namespace.Namespace model. If not nil this will // bind the namespace.Namespace model to any Variable models that are // created. If not nil this will append a WHERE clause on the namespace_id // column for all SELECT queries performed. Namespace *namespace.Namespace }
Store is the type for creating and modifying Variable models in the database.
func NewStore ¶
NewStore returns a new Store for querying the variables table. Each of the given models is bound to the returned Store.
func (*Store) All ¶
All returns a slice of Variable models, applying each query.Option that is given. The namespace.WhereCollaborator option is applied to the *user.User bound database, and the database.Where option is applied to the *namespace.Namespace bound database.
func (*Store) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User or namespace.Namespace.
func (*Store) Get ¶
All returns a single Variable model, applying each query.Option that is given. The namespace.WhereCollaborator option is applied to the *user.User bound database, and the database.Where option is applied to the *namespace.Namespace bound database.
func (*Store) Index ¶
func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Variable, database.Paginator, error)
Index returns the paginated results from the variables table depending on the values that are present in url.Values. Detailed below are the values that are used from the given url.Values,
key - This applies the database.Search query.Option using the value of key
func (*Store) Load ¶
func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Variable models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls Store.All under the hood, so any bound models will impact the models being loaded.
func (*Store) New ¶
New returns a new Variable binding any non-nil models to it from the current Store.
type Variable ¶
type Variable struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` AuthorID int64 `db:"author_id"` NamespaceID sql.NullInt64 `db:"namespace_id"` Key string `db:"key"` Value string `db:"value"` CreatedAt time.Time `db:"created_at"` Author *user.User `db:"-"` User *user.User `db:"-"` Namespace *namespace.Namespace `db:"-"` }
Variable is the type that represents a variable that has been set by a user.
func FromContext ¶
FromContext returns the Variable model from the given context, if any.
func (*Variable) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User or namespace.Namespace.
func (*Variable) Endpoint ¶
Endpoint returns the endpoint to the current Variable database, with the given URI parts appended to it.
func (*Variable) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Variable values under each key. If any of the User, or Namespace bound models exist on the Variable, then the JSON representation of these models will be returned in the map, under the user, and namespace keys respectively.
func (*Variable) SetPrimary ¶
SetPrimary implements the database.Model interface.