Skip to content

Instantly share code, notes, and snippets.

@mikebobadilla
Created July 29, 2015 05:55
Show Gist options
  • Save mikebobadilla/f07b1dc19f6326b8b064 to your computer and use it in GitHub Desktop.
Save mikebobadilla/f07b1dc19f6326b8b064 to your computer and use it in GitHub Desktop.
var Promise = require('bluebird');
var knex = require('knex')({
client: 'mysql',
connection: {
host: '127.0.0.1',
user: 'root',
password: '',
database: 'steam',
charset: 'utf8'
}
});
var bookshelf = require('bookshelf')(knex);
var User = bookshelf.Model.extend({
tableName: 'users'
});
var Users = bookshelf.Collection.extend({
model: User
});
setTimeout(function(){
Users.forge()
.fetch()
.then(function (collection) {
console.log(collection.models[0].attributes);
})
.catch(function (err) {
console.log(err);
});
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment