Last active
April 28, 2016 10:27
-
-
Save leemason/1b6f0ac57ab259849d5d74361b9121ad to your computer and use it in GitHub Desktop.
Example usage of SQL Mason.
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
var mason = new Mason(); | |
sql = mason | |
.select('*') | |
.from('users') | |
.where(function(builder){ | |
builder | |
.where('first_name', 'lee') | |
.where('last_name', 'mason'); | |
}) | |
.orWhere('email', '[email protected]'); | |
sql.toSql() >> 'select * from `users` where (`first_name` = ? and `last_name` = ?) or `email` = ?;'; |
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
var mason = new Mason(); | |
sql = mason | |
.table('users') | |
.where('id', 1) | |
.update({ | |
first_name: 'lee', | |
last_name: 'mason' | |
}); | |
sql.toSql() >> 'update `users` set `first_name` = ?, `last_name` = ? where `id` = ?;'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment