pg and Node

Bringing it all together

Objectives

  1. Use a node.js package to issue queries to Postgres
  2. Set up and configure your database on a server
  3. Issue queries inside of requests

You'll revisit these!

pg

var pg = require('pg');

var db;

pg.connect("postgres://localhost:5432/pokemon", function(err, client, done) {
    db = client;
});

In your node REPL:

In an empty folder:

npm init 

npm install pg --save

pg

db.query("SELECT * FROM pokemon;", function (err, rows) {



});

Objectives

  1. Something
  2. Something Else
  3. Some other thing

This is revisiting Post It, time for a CFU

Discuss:

What is Something?

Where would we use Something?

3 ways to refactor your last project into Something-style

You can use the technique Cold Calling

You can also use Turn and Talk, Batch Process, or Think Pair Share

Something Else

Setup

Something else

What does this evaluate to?

Objectives

  1. Something
  2. Something Else
  3. Some other thing

Revisiting Post It!

Time for a CFU!

Reflect

Show how to use Something Else on your whiteboards

How do we use Something Else with Something?

This technique is called Everybody Writes

Take Note:

Something Else:

  1. Do Something
  2. Do Another Thing
  3. One More Thing
  4. These Are The Steps
  5. I have Named The Steps

This technique is called Name The Steps

Anytime you Name The Steps, make them write it with BOARD = PAPER

Some other thing

Objectives

  1. Something
  2. Something Else
  3. Some other thing

Check Your Understanding

  1. Pull up Something
  2. Use Something Else
  3. Try Some Other Thing
  4. Check your work and refactor

This technique is called Name The Steps

They should write it down, the BOARD = PAPER techique

Exercise:

10 Minutes: try to do Something

10 Minutes: Do Something Else, Recursively

25 Minutes: Use Some Other Thing to fix the problem with Something Else

This technique is called Brighten Lines

pg and Node.js - incomplete

By LizTheDeveloper

pg and Node.js - incomplete

  • 1,348