Created
November 19, 2012 21:06
-
-
Save booo/4113898 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
| pg = require "./" | |
| utils = require "./lib/utils" | |
| utils.prepareValue = (val) -> | |
| if val instanceof Date then return JSON.stringify val | |
| if typeof val is 'undefined' then return null | |
| if val instanceof Array then return "{#{val.join ", "}}" | |
| val is null ? null : val.toString() | |
| pg.connect "pg://postgres:testing@localhost/postgres", (error, connection) -> | |
| if error | |
| console.error error | |
| else | |
| callback = (error, result) -> | |
| if error then console.error error | |
| else console.log result.rows | |
| connection.query "CREATE TEMP TABLE foo (a integer[])", callback | |
| connection.query "INSERT INTO foo (a) VALUES ($1)", [[1,2,3]], callback | |
| connection.query "SELECT * FROM foo", [], callback | |
| pg.end() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment