Skip to content

Instantly share code, notes, and snippets.

@Shurlow
Last active July 27, 2017 14:42
Show Gist options
  • Select an option

  • Save Shurlow/7a2ae7ff7ff0b4b562448dfbfd6ce8e9 to your computer and use it in GitHub Desktop.

Select an option

Save Shurlow/7a2ae7ff7ff0b4b562448dfbfd6ce8e9 to your computer and use it in GitHub Desktop.
Knex.js Instructor Notes

Knex Instructor Notes

Objectives

  • Explain what Knex.js is.
  • Explain why Knex.js is useful.
  • Use Knex.js to operate on PostgreSQL tables.

Explain what Knex.js is

Turn to your neighbor and explain what Knex.js is in your own words. Be prepared to share with the class.

Explain why Knex.js is useful

Turn to your neighbor and explain why Knex.js is useful in your own words. How does it help prevent against potential malicious attacks?

Use Knex.js to operate on PostgreSQL tables

clone the lesson repo: git clone https://github.com/Shurlow/knex-lesson.git

install dependencies: npm i

Start with a clean movies database:

dropdb movie_junkies_dev
createdb movie_junkies_dev
curl -fsSL https://git.io/voXVD | psql movie_junkies_dev
  • Hook up knexfile.js to the database and require at the top of index.js
  • Complete the functions in index.js (Note: each function is immediately invoked in a commend bellow it. Uncomment any function call that you want to test out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment