Skip to content

Instantly share code, notes, and snippets.

@eamonnmcevoy
Last active March 14, 2017 12:04
Show Gist options
  • Save eamonnmcevoy/789bf62664373a5779710e879c34441c to your computer and use it in GitHub Desktop.
Save eamonnmcevoy/789bf62664373a5779710e879c34441c to your computer and use it in GitHub Desktop.
package mongo
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"go_rest_api/pkg"
)
type UserService struct {
collection *mgo.Collection
}
func NewUserService(session *Session, dbName string, collectionName string) *UserService {
collection := session.GetCollection(dbName, collectionName)
collection.EnsureIndex(userModelIndex())
return &UserService {collection}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment