Created
July 5, 2018 13:49
-
-
Save davidcostadev/a2920d2b52d86f84d83e28bb9319a6d7 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
| console.clear(); | |
| const fieldsQuery = (fields) => fields | |
| .map(field => field | |
| .split(' as ') | |
| .map(each => each.trim()) | |
| .join(' as ') | |
| ).join(', '); | |
| const select = (sql) => (...fields) => ( | |
| query({ | |
| ...sql, | |
| select: `SELECT \n\t ${fieldsQuery(fields)}` | |
| }) | |
| ); | |
| const table = (sql) => (table) => ( | |
| query({ | |
| ...sql, | |
| table: `FROM \n\t ${table}` | |
| }) | |
| ) | |
| const where = (sql) => (fields) => { | |
| return | |
| } | |
| const build = (sql) => () => { | |
| return sql | |
| } | |
| const query = (sql = {}) => ({ | |
| select: select(sql), | |
| table: table(sql), | |
| build: build(sql) | |
| }) | |
| console.log(query().table('TBL_OFERTAS').select('id', 'NAME as name ', 'email').build()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment