       console.log selector, options
       JInvitation.some selector, options, callback
 
+  # search searches database with given query string, adds `starting
+  # with regex` around query param
   @search$:  permit 'send invitations',
     success: (client, query, options, callback) ->
       selector = { $or : [ {'name' : ///^#{query}/// }, {'email' : ///^#{query}/// } ]}

      'send invitations' : ['moderator', 'admin']
    indexes         :
      code          : 'unique'
      # TODO create a compound index on groupName and
    sharedMethods   :

      instance:

        type        : Date
        default     : -> new Date

  accept$: secure (client, callback) ->
    { delegate } = client.connection
    @accept delegate, callback

  accept: (account, callback) ->
    operation = $set : { status: 'accepted' }
    @update operation, callback

  # remove deletes an invitation from database
  remove$: permit 'send invitations',
    success: (client, callback) ->
      @remove callback

  # some selects result set for invitations, it adds group name automatically
  @some$:  permit 'send invitations',
