{Model, ObjectId, Validator} = require '../../../lib'
Meta  = require '../../../bundles/meta'

class User extends Model
  
  @setSchema
    username    :
      type      : String
      required  : yes
    email       :
      type      : String
#      email     : yes
      validate  : ['whoopsie daisy!', (value, check)-> check(value).isEmail()]
    fullName    : String
    
class Comment extends Model

  @setSchema
    author      : ObjectId
    subject     : String
    body        :
      type      : String
      required  : yes

class Post extends Model

  @setSchema
    author      : ObjectId
    title       :
      type      : String
      required  : yes
    body        :
      type      : String
    comments    : [Comment]
    meta        : Meta

  addComment:(comment)->
    @comments.push comment
    
[@User, @Comment, @Post] = [User, Comment, Post]