Skip to content

Instantly share code, notes, and snippets.

@MEPF
Forked from meltingice/gist:4740082
Created January 22, 2014 20:53
Show Gist options
  • Save MEPF/8567174 to your computer and use it in GitHub Desktop.
Save MEPF/8567174 to your computer and use it in GitHub Desktop.
Model.findByName = (name, value, cb) ->
model = new @
@find "SELECT * FROM #{model.tableName()} WHERE `#{name}`=`#{value}` LIMIT 1", cb
class User extends Model
User.findByName 'email', '[email protected]', (results) ->
console.log results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment