Last active
August 29, 2015 13:57
-
-
Save TyOverby/9614876 to your computer and use it in GitHub Desktop.
DB js
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 dblib = require('somedb'); | |
| var wr = require('mywrapper'); | |
| var db = wr(dblib); | |
| // query | |
| function queryExample() { | |
| var client = yield db.connect('postgres://postgres:1234@localhost/postgres'); | |
| var table = yield client.getTable('users'); | |
| var result = yield table.queryFirst({ name: 'ty' }); | |
| console.log(result); // { name: 'ty', age: 20, last_name: 'overby'} | |
| } | |
| // update | |
| function updateExample() { | |
| var client = yield db.connect('postgres://postgres:1234@localhost/postgres'); | |
| var table = yield client.getTable('users'); | |
| yield client.insert({name: 'ty', age: 20, last_name: 'overby'}); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment