Skip to content

Commit

Permalink
Fix mistakes and syntax error in example
Browse files Browse the repository at this point in the history
Also use SQLite so new users can more easily copy and paste and try it out right away
Fixes #488
  • Loading branch information
bendrucker committed Sep 16, 2014
1 parent d819f67 commit 7ef13ed
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions README.md
Expand Up @@ -24,8 +24,10 @@ We have several examples [on the website](http://knexjs.org). Here is the first

```js
var knex = require('knex')({
dialect: 'mysql',
connection: process.env.DB_CONNECTION_STRING
dialect: 'sqlite3',
connection: {
filename: './data.db'
}
});

// Create a table
Expand All @@ -48,13 +50,13 @@ knex.schema.createTable('users', function(table) {

// ...and using the insert id, insert into the other table.
.then(function(rows) {
return knex.table('accounts').insert({account_name: 'knex', user_id: knex.rows[0]});
});
return knex.table('accounts').insert({account_name: 'knex', user_id: rows[0]});
})

// Query both of the rows.
.then(function() {
return knex('users')
.join('accounts', 'accounts.id')
.join('accounts', 'users.id', 'accounts.user_id')
.select('users.user_name as user', 'accounts.account_name as account');
})

Expand Down

0 comments on commit 7ef13ed

Please sign in to comment.