Last active
December 12, 2015 07:58
-
-
Save meltingice/4740082 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Model.findByName = (name, value, cb) -> | |
| model = new @ | |
| @find "SELECT * FROM #{model.tableName()} WHERE `#{name}`=`#{value}` LIMIT 1", cb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Seems that there is a bug in the 'find' method - the SQL isn't respected for some reason:
SELECT * FROM
manufacturerWHEREid= 'SELECT * FROM manufacturer WHEREname=AMD' LIMIT 1