func (r *mongoDatabase) RetrieveJob(jobID string) (types.Job, error) {
	c := r.db.C("jobs")
	result := types.Job{}
	err := c.Find(bson.M{"id": jobID}).One(&result)
	return result, err
}
RetrieveJob retrieves one job from the database
package db
import (
	"errors"
	"sync"
	"github.com/flavioribeiro/gonfig"
	"github.com/snickers/snickers/types"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)
type mongoDatabase struct {
	db *mgo.Database
}
var databaseMongoInit sync.Once
var mongoInstance *mongoDatabase
func getMongoDatabase(cfg gonfig.Gonfig) (Storage, error) {
	var initErr error
	databaseMongoInit.Do(func() {
		mongoInstance = &mongoDatabase{}
	})
	mongoHost, _ := cfg.GetString("MONGODB_HOST", "")
	session, err := mgo.Dial(mongoHost)
	if err != nil {
		return nil, err
	}
	if mongoInstance.db == nil {
		session.SetMode(mgo.Monotonic, true)
		mongoInstance.db = session.DB("snickers")
	}
	return mongoInstance, initErr
}
func (r *mongoDatabase) ClearDatabase() error {
	return r.db.DropDatabase()
}
func (r *mongoDatabase) StorePreset(preset types.Preset) (types.Preset, error) {
	if _, err := r.RetrievePreset(preset.Name); err == nil {
		return types.Preset{}, errors.New("Error 409: Preset already exists, please update instead.")
	}
	c := r.db.C("presets")
	err := c.Insert(preset)
	if err != nil {
		return types.Preset{}, err
	}
	return preset, nil
}
func (r *mongoDatabase) UpdatePreset(presetName string, newPreset types.Preset) (types.Preset, error) {
	c := r.db.C("presets")
	err := c.Update(bson.M{"name": presetName}, newPreset)
	if err != nil {
		return types.Preset{}, err
	}
	return newPreset, nil
}
func (r *mongoDatabase) RetrievePreset(presetName string) (types.Preset, error) {
	c := r.db.C("presets")
	result := types.Preset{}
	err := c.Find(bson.M{"name": presetName}).One(&result)
	return result, err
}
func (r *mongoDatabase) GetPresets() ([]types.Preset, error) {
	results := []types.Preset{}
	c := r.db.C("presets")
	err := c.Find(nil).All(&results)
	return results, err
}
func (r *mongoDatabase) DeletePreset(presetName string) (types.Preset, error) {
	result, err := r.RetrievePreset(presetName)
	if err != nil {
		return types.Preset{}, err
	}
	c := r.db.C("presets")
	err = c.Remove(bson.M{"name": presetName})
	if err != nil {
		return types.Preset{}, err
	}
	return result, nil
}
func (r *mongoDatabase) DeleteJob(jobID string) (types.Job, error) {
	result, err := r.RetrieveJob(jobID)
	if err != nil {
		return types.Job{}, err
	}
	c := r.db.C("jobs")
	err = c.Remove(bson.M{"ID": jobID})
	if err != nil {
		return types.Job{}, err
	}
	return result, nil
}
func (r *mongoDatabase) StoreJob(job types.Job) (types.Job, error) {
	c := r.db.C("jobs")
	err := c.Insert(job)
	if err != nil {
		return types.Job{}, err
	}
	return job, nil
}