 _ = require 'underscore'
 
 module.exports = class User extends Model
-  @validateData:
-    group: ['admin','user','trial']
+  #传入model
+  # @validateData:
+  #   group: ['admin','user','trial']
   # 必须重写
   @create: (data) ->
     new User data

  #     user.removeFromGroup 'user',(err,result)->
  #       console.log result
  removeFromGroup: (group,callback) ->
    throw 'group must be string' if not _.isString group
    throw 'unknown group' if group not in @constructor.validateData['group']
    @update $pull:
      group: group
    ,callback
  #       console.log result
  addToGroup: (group,callback) ->
    group = [].push group if not _.isArray group
    # for i in group
      # throw 'unknown group' if i not in @constructor.validateData['group']
    @update $addToSet:
      group:
        $each:group
