         type        : Date
         default     : -> new Date
 
-  # remove deleted invitation from database
+  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
-
-  accept$: secure (client, callback) ->
-    { delegate } = client.connection
-    @accept delegate, callback
-
-  accept: (account, callback) ->
-    operation = $set : { status: 'accepted' }
-    @update operation, callback
-
 
   # some selects result set for invitations, it adds group name automatically
   @some$:  permit 'send invitations',

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

      instance:

      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}/// } ]}
