Skip to content

Instantly share code, notes, and snippets.

@eamonnmcevoy
Last active March 14, 2017 09:13
Show Gist options
  • Save eamonnmcevoy/eef8f7b8b6e9993a3f8ec48e03be37a8 to your computer and use it in GitHub Desktop.
Save eamonnmcevoy/eef8f7b8b6e9993a3f8ec48e03be37a8 to your computer and use it in GitHub Desktop.
Create(u *root.User)
func(p *UserService) Create(u *root.User) error {
user := newUserModel(u)
return p.collection.Insert(&user)
}
func(p *UserService) GetByUsername(username string) (*root.User,error) {
model := userModel{}
err := p.collection.Find(bson.M{"username": username}).One(&model)
return model.toRootUser(), err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment