func (op Operation) Validate() error {
	switch op.Event {
	case "insert", "update", "delete":
	default:
		return fmt.Errorf("invalid event name: %s", op.Event)
	}
	return op.Data.Validate()
}
Validate ensures an operation has the proper syntax
package oplog
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"strings"
	"time"
	"gopkg.in/mgo.v2/bson"
)
type Operation struct {
	ID    *bson.ObjectId `bson:"_id,omitempty"`
	Event string         `bson:"event"`
	Data  *OperationData `bson:"data"`
}
type OperationData struct {
	Timestamp time.Time `bson:"ts" json:"timestamp"`
	Parents   []string  `bson:"p" json:"parents"`
	Type      string    `bson:"t" json:"type"`
	ID        string    `bson:"id" json:"id"`
	Ref       string    `bson:"-,omitempty" json:"ref,omitempty"`
}
func NewOperation(event string, time time.Time, objID, objType string, objParents []string) *Operation {
	id := bson.NewObjectId()
	return &Operation{
		ID:    &id,
		Event: event,
		Data: &OperationData{
			Timestamp: time,
			ID:        objID,
			Type:      objType,
			Parents:   objParents,
		},
	}
}
func (op Operation) GetEventID() LastID {
	return &OperationLastID{op.ID}
}