     unless showClosed == 'true' or showClosed == true
       query.open = true
     console.log "[HTTP] request to list competitions by owner (ownerId=#{ownerId}, showClosed=#{showClosed})"
-    @api.find(query)
+    @api.list(query)
 
 index =
   route: '/'
   method: 'GET'
   filters: [filters.FromUrlParams, filters.FromQueryParams]
-  emptyResult: []
   handler: ->
     showClosed = @params.showClosed
     query = {}
     unless showClosed == 'true' or showClosed == true
       query.open = true
     console.log "[HTTP] request to list competitions (showClosed=#{showClosed})"
-    @api.find(query)
+    @api.list(query)
+
+getByMembership =
+  route: '/by-membership/:userId'
+  method: 'GET'
+  filters: [filters.FromUrlParams, filters.FromQueryParams]
+  handler: ->
+    userId = @params.userId
+    showClosed = @params.showClosed == 'true' or @params.showClosed == true
+    competitionsQuery = {}
+    membershipApi = @createApi(@adapter, @models.competition_membership)
+    console.log "[HTTP] request to list competitions by membership (userId=#{userId}, showClosed=#{showClosed})"
+    membershipApi.list(user_id: userId)
+    .then((memberships) =>
+      if memberships?.length == 0
+        console.log "[HTTP] found no competition memberships (userId=#{userId})"
+        return []
+
+      membershipIds = memberships.map((membership) ->
+        _id: membership.competition_id
+      )
+      anyCompetition = { $or: membershipIds }
+      dbQuery = @model.find(anyCompetition)
+      unless showClosed
+        dbQuery.where('open').equals(true)
+      Q(dbQuery.exec())
+    )
+
+end =
+  route: '/:id/end'
+  filters: [filters.FromUrlParams]
+  method: 'POST'
+  handler: ->
+    competitionId = @params.id
+    console.log "[HTTP] end competition (competitionId=#{competitionId})"
+    @api.update(
+      { _id: competitionId },
+      { open: false }
+    )
+
+restart =
+  route: '/:id/restart'
+  filters: [filters.FromUrlParams]
+  method: 'POST'
+  handler: ->
+    competitionId = @params.id
+    console.log "[HTTP] start competition (competitionId=#{competitionId})"
+    @api.update(
+      { _id: competitionId },
+      { open: true }
+    )
 
 module.exports = new CompetitionResource
  getEndpoints: -> [
    getByOwner
    index
    'show'
    'update'
    'destroy'

Q = require 'q'
{models, Resource, filters} = require '../resource_helper'

class CompetitionResource extends Resource
