models

package
v0.0.0-...-4e988be Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2018 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCollection = errors.New("invalid collection")

ErrInvalidCollection is returned when the collection specified is invalid

View Source
var ErrNotFound = mgo.ErrNotFound

ErrNotFound is the error to return when no records were found

View Source
var ErrObjID = errors.New("invalid object id")

ErrObjID is the error to return when an Object ID is invalid

View Source
var TBLCHANGES = "Changes"

TBLCHANGES is the name of the collection for users

View Source
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 Changes

type Changes []Change

Changes is a slice of Change objects

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 Signatures

type Signatures []Signature

Signatures is a slice of Signature objects

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

type Users

type Users []User

Users is a slice of User objects

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL