Skip to content

Instantly share code, notes, and snippets.

@TyOverby
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save TyOverby/9614876 to your computer and use it in GitHub Desktop.

Select an option

Save TyOverby/9614876 to your computer and use it in GitHub Desktop.
DB js
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