1616var extend = require ( 'lodash' ) . assign ;
1717var mysql = require ( 'mysql' ) ;
1818
19- module . exports = function ( config ) {
19+ module . exports = function ( config ) {
2020
2121 function getConnection ( ) {
2222 return mysql . createConnection ( extend ( {
@@ -30,7 +30,7 @@ module.exports = function(config) {
3030 var connection = getConnection ( ) ;
3131 connection . query (
3232 'SELECT * FROM `books` LIMIT ? OFFSET ?' , [ limit , token ] ,
33- function ( err , results ) {
33+ function ( err , results ) {
3434 if ( err ) { return cb ( err ) ; }
3535 var hasMore = results . length === limit ? token + results . length : false ;
3636 cb ( null , results , hasMore ) ;
@@ -43,7 +43,7 @@ module.exports = function(config) {
4343 // [START create]
4444 function create ( data , cb ) {
4545 var connection = getConnection ( ) ;
46- connection . query ( 'INSERT INTO `books` SET ?' , data , function ( err , res ) {
46+ connection . query ( 'INSERT INTO `books` SET ?' , data , function ( err , res ) {
4747 if ( err ) { return cb ( err ) ; }
4848 read ( res . insertId , cb ) ;
4949 } ) ;
@@ -54,7 +54,7 @@ module.exports = function(config) {
5454 function read ( id , cb ) {
5555 var connection = getConnection ( ) ;
5656 connection . query (
57- 'SELECT * FROM `books` WHERE `id` = ?' , id , function ( err , results ) {
57+ 'SELECT * FROM `books` WHERE `id` = ?' , id , function ( err , results ) {
5858 if ( err ) { return cb ( err ) ; }
5959 if ( ! results . length ) {
6060 return cb ( {
@@ -71,7 +71,7 @@ module.exports = function(config) {
7171 function update ( id , data , cb ) {
7272 var connection = getConnection ( ) ;
7373 connection . query (
74- 'UPDATE `books` SET ? WHERE `id` = ?' , [ data , id ] , function ( err ) {
74+ 'UPDATE `books` SET ? WHERE `id` = ?' , [ data , id ] , function ( err ) {
7575 if ( err ) { return cb ( err ) ; }
7676 read ( id , cb ) ;
7777 } ) ;
@@ -95,7 +95,6 @@ module.exports = function(config) {
9595 } ;
9696} ;
9797
98-
9998if ( ! module . parent ) {
10099 var prompt = require ( 'prompt' ) ;
101100 prompt . start ( ) ;
@@ -104,7 +103,7 @@ if (!module.parent) {
104103 'Running this script directly will allow you to initialize your mysql ' +
105104 'database.\n This script will not modify any existing tables.\n' ) ;
106105
107- prompt . get ( [ 'host' , 'user' , 'password' ] , function ( err , result ) {
106+ prompt . get ( [ 'host' , 'user' , 'password' ] , function ( err , result ) {
108107 if ( err ) { return ; }
109108 createSchema ( result ) ;
110109 } ) ;
@@ -129,7 +128,7 @@ function createSchema(config) {
129128 '`createdBy` VARCHAR(255) NULL, ' +
130129 '`createdById` VARCHAR(255) NULL, ' +
131130 'PRIMARY KEY (`id`));' ,
132- function ( err ) {
131+ function ( err ) {
133132 if ( err ) { throw err ; }
134133 console . log ( 'Successfully created schema' ) ;
135134 connection . end ( ) ;
0 commit comments