Skip to content

Instantly share code, notes, and snippets.

@vadimdemedes
Created May 13, 2012 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadimdemedes/2688643 to your computer and use it in GitHub Desktop.
Save vadimdemedes/2688643 to your computer and use it in GitHub Desktop.
Accessing fields in hooks and validation methods
Mongorito = require 'mongorito'
Mongorito.connect ['127.0.0.1:27017/databaseName']
class User
keys: ['email', 'api_token']
afterCreate: ->
@email
@api_token
validateEmail: (valid) ->
valid someEmailRegex.test(@email)
User = Mongorito.bake User
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment