Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used async/await handler; Always assign new knex connection to preven…
…t left open connections; Refactored response-mapping-templates
- Loading branch information
Showing
24 changed files
with
239 additions
and
421 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// eslint-disable-next-line | ||
const mysql = require('mysql'); | ||
|
||
module.exports = { | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
const connection = require('./../knexfile'); | ||
const knex = require('knex')(process.env.NODE_ENV === 'production' ? connection.production : connection.dev); | ||
|
||
async function getAuthor(args) { | ||
try { | ||
const getAuthorQuery = knex('author') | ||
.where('id', args.id) | ||
.first(); | ||
|
||
const result = await getAuthorQuery; | ||
|
||
return result | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
async function getAuthor(knex, args) { | ||
return await knex('author') | ||
.where('id', args.id) | ||
.first(); | ||
} | ||
|
||
async function getAuthors(args) { | ||
try { | ||
const getAuthorsQuery = knex('author') | ||
.orderBy('lastname', 'asc'); | ||
|
||
const result = await getAuthorsQuery; | ||
|
||
return result | ||
} catch (err) { | ||
console.log(err); | ||
} | ||
async function getAuthors(knex, args) { | ||
return await knex('author') | ||
.orderBy('lastname', 'asc'); | ||
} | ||
|
||
export { getAuthor, getAuthors }; |
Oops, something went wrong.