func (s *TaskDAOMongo) GetByID(ID string) (*model.Task, error) {
	if _, err := uuid.FromString(ID); err != nil {
		return nil, ErrInvalidUUID
	}
	session := s.session.Copy()
	defer session.Close()
	task := model.Task{}
	c := session.DB("").C(collection)
	err := c.Find(bson.M{"id": ID}).One(&task)
	if err != nil && err == mgo.ErrNotFound {
		return nil, ErrNotFound
	}
	return &task, err
}
GetByID returns a task by its ID
package dao
import (
	"github.com/Sfeir/golang-200/model"
	"github.com/satori/go.uuid"
	logger "github.com/sirupsen/logrus"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)
var _ TaskDAO = (*TaskDAOMongo)(nil)
const (
	collection = "tasks"
	index      = "id"
)
type TaskDAOMongo struct {
	session *mgo.Session
}
func NewTaskDAOMongo(session *mgo.Session) TaskDAO {
	err := session.DB("").C(collection).EnsureIndex(mgo.Index{
		Key:        []string{index},
		Unique:     true,
		DropDups:   true,
		Background: true,
		Sparse:     true,
	})
	if err != nil {
		logger.WithField("error", err).Warn("mongo db connection")
	}
	return &TaskDAOMongo{
		session: session,
	}
}