     throw "must provide db connection" unless @db
 
   createUser: (name) ->
-    create = Q.nbind(User.create, User)
-    create(name: name)
+    Q(User.create(name: name).exec())
     .then (val) ->
       bus.emit('user:created', val)
       val

  listUsers: (userId) ->
    if userId?
      query = _id: ObjectID(userId)
    find = Q.nbind(User.find, User)
    find(query)

  listCompetitionsByOwner: (ownerId) ->
    if not userId?

      return errPromise

    query = owner_id: ObjectID(userId)
    Q(Competition.find(query).exec())

  listCompetitions: ->
    Q(Competition.find().exec())

  listCompetitionsByMembership: (userId) ->

  startCompetition: (userId, name) ->
    Q(
      Competition.create(
        name: name
        owner_id: userId
        open: true
        type: 'multi'
        participants: [ObjectID(userId)]
      ).exec()
    ).then (competition) ->
      bus.emit('competition:started', competition)
      competition

  endCompetition: (competitionId) ->
    Q(
      Competition.findOneAndUpdate(
        { _id: competitionId },
        { open: false }
      )
    ).then (competition) ->
      bus.emit('competition:ended', competition)
      competition

  voteFor: (userId, competitionId, choiceId) ->
    query =
      user_id: userId
    toUpdate =
      choice_id: choiceId

    Q(Vote.findByIdAndUpdate(query, toUpdate).exec())
    .then (vote) ->
      bus.emit('vote:cast', vote)
      vote
