Documentation ¶
Index ¶
- Variables
- type Change
- type Changes
- type Datasource
- func (d *Datasource) Close()
- func (d *Datasource) GetChanges(id string) (Changes, error)
- func (d *Datasource) GetUsers(id string) (Users, error)
- func (d *Datasource) InsertChange(change Change) (bson.ObjectId, error)
- func (d *Datasource) InsertUser(user User) (bson.ObjectId, error)
- func (d *Datasource) RemoveChange(id string) error
- func (d *Datasource) RemoveUser(id string) error
- func (d *Datasource) UpdateChange(change Change) error
- func (d *Datasource) UpdateUser(user User) error
- func (d *Datasource) ValidateUser(username, password string) (bool, error)
- type Signature
- type Signatures
- type User
- type Users
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCollection = errors.New("invalid collection")
ErrInvalidCollection is returned when the collection specified is invalid
var ErrNotFound = mgo.ErrNotFound
ErrNotFound is the error to return when no records were found
var ErrObjID = errors.New("invalid object id")
ErrObjID is the error to return when an Object ID is invalid
var TBLCHANGES = "Changes"
TBLCHANGES is the name of the collection for users
var TBLUSERS = "Users"
TBLUSERS is the name of the collection for users
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change struct { ID bson.ObjectId `bson:"_id,omitempty" json:"id"` Created Signature `bson:"created" json:"created"` Requested Signature `bson:"requested" json:"requested"` Scheduled *time.Time `bson:"scheduled" json:"scheduled"` ScheduledDateOnly bool `bson:"scheduleddateonly" json:"scheduledDateOnly"` Assigned bson.ObjectId `bson:"assigned,omitempty" json:"assigned"` Executed Signature `bson:"executed" json:"executed"` Type string `bson:"type" json:"type"` Risk string `bson:"risk" json:"risk"` Title string `bson:"title" json:"title"` Content string `bson:"content" json:"content"` Signatures Signatures `bson:"signatures" json:"signatures"` OverrideSignatures Signatures `bson:"overridesignatures" json:"overrideSignatures"` }
Change is an object contianing change information
type Datasource ¶
type Datasource struct { Database *mgo.Database DatabaseName string DSN string // contains filtered or unexported fields }
Datasource is an object containing the database info and connection
func NewDatasource ¶
func NewDatasource(config *config.Config) (*Datasource, error)
NewDatasource builds and connects to a database instance, then returns a Datasource object
func (*Datasource) Close ¶
func (d *Datasource) Close()
Close terminates a connection to the database
func (*Datasource) GetChanges ¶
func (d *Datasource) GetChanges(id string) (Changes, error)
GetChanges is a handler to return the specified user objects
func (*Datasource) GetUsers ¶
func (d *Datasource) GetUsers(id string) (Users, error)
GetUsers returns the specified user objects
func (*Datasource) InsertChange ¶
func (d *Datasource) InsertChange(change Change) (bson.ObjectId, error)
InsertChange inserts a new change object
func (*Datasource) InsertUser ¶
func (d *Datasource) InsertUser(user User) (bson.ObjectId, error)
InsertUser inserts a new user object
func (*Datasource) RemoveChange ¶
func (d *Datasource) RemoveChange(id string) error
RemoveChange removes a specified change object
func (*Datasource) RemoveUser ¶
func (d *Datasource) RemoveUser(id string) error
RemoveUser removes a specified user object
func (*Datasource) UpdateChange ¶
func (d *Datasource) UpdateChange(change Change) error
UpdateChange updates a specified change object
func (*Datasource) UpdateUser ¶
func (d *Datasource) UpdateUser(user User) error
UpdateUser updates a specified user object
func (*Datasource) ValidateUser ¶
func (d *Datasource) ValidateUser(username, password string) (bool, error)
ValidateUser checks the user credentials in the database
type Signature ¶
type Signature struct { UserID bson.ObjectId `bson:"userid,omitempty" json:"userid"` Signed *time.Time `bson:"signed" json:"signed"` }
Signature is an object containing user ID and time signed
type User ¶
type User struct { ID bson.ObjectId `bson:"_id,omitempty" json:"id"` UserName string `bson:"username" json:"username"` FirstName string `bson:"firstname" json:"firstname"` MiddleName string `bson:"middlename" json:"middlename"` LastName string `bson:"lastname" json:"lastname"` Email string `bson:"email" json:"email"` Password string `bson:"password" json:"password"` }
User is an object containing user information