Skip to content

Instantly share code, notes, and snippets.

@meltingice
Last active December 12, 2015 07:58
Show Gist options
  • Save meltingice/4740082 to your computer and use it in GitHub Desktop.
Save meltingice/4740082 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
@mlaccetti
Copy link

Seems that there is a bug in the 'find' method - the SQL isn't respected for some reason:

SELECT * FROM manufacturer WHERE id = 'SELECT * FROM manufacturer WHERE name=AMD' LIMIT 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment