=== checks that something is equal to something else
= sets something equal to something else
From front end to back end:
put all front end code in own folder (common name is static or public)
then in that directory as an index.html
touch creates a new folder
When putting in VS code instead of Repil
we can eliminate the backend base Url - they are hosted from the same server. So we can use relative paths
app.use(express.static(‘public’));- tell app it is responsible for serving whatever is in
we don’t need to use cors anywhere because we have our own sever
we can use a relative path.
app.use(express.static(‘public’));
Deploy to heroic -
Do heroku - create rbi-get-things-done
Will create a place
then git push heroku master
SQL stores things in databases - more robust than on the server
Heroku.- deployment platform. At Rbi we use AWS.
stores things for long term!
SQL
if a column is serial, the first entry in the table has an id of 1
var char - varying number of characters
not null - pols are not allowed to put as empty value
can restrict answers to SQL code:
rbi-postgres-demo::DATABASE=> INSERT INTO bootcamp_people (age, last_name, first_name, sql_confidence, current_mood)
rbi-postgres-demo::DATABASE-> VALUES (28, 'Caplan', 'Alexandra', 5, 'Happy');
INSERT 0 1
rbi-postgres-demo::DATABASE=>
Select avg (age) from bootcamp)people;
Select last_name from bootcamp_people where age <30;
Select from bootcamp_people where first_name ILIKE ‘%han’;
Select
From bootcamp_people
Where first_name
Can also do counts, averages etc:
Select count(id) where mood = ‘Happy’;
Getting in sql:
Pg - links to posgress
Lets us write sequel
yarn add pg :
Yarn start = starts the server
Control c stops
How to create tables for our data? CREATE TABLE.
How to create incrementing id - id SERIAL PRIMARY KEY,
If we don't want them to be zero characters, we can put NOT NULL
db.query( CREATE TABLE tasks( id SERIAL PRIMARY KEY, description VARCHAR(128) NOT NULL, completed BOOLEAN NOT NULL DEFAULT FALSE ); )
$1 can stop people putting malicious sql somewhere
Get tasks - when the user asks for the task
Postman asks api, which asks database, api responds with a json representation.
When you make something await, you need to make the function asynchronous!
Object.entries - you get an array - first thing is key, second thing is value
To connect to Heroku, pass a connection string to the argument variable in the Pool command.{connection string: process.env.DATABASE_URL });
Today I learned.....
=== checks that something is equal to something else = sets something equal to something else
From front end to back end:
When putting in VS code instead of Repil
app.use(express.static(‘public’));
Deploy to heroic - Do heroku - create rbi-get-things-done Will create a place
SQL stores things in databases - more robust than on the server Heroku.- deployment platform. At Rbi we use AWS.
SQL
rbi-postgres-demo::DATABASE=> INSERT INTO bootcamp_people (age, last_name, first_name, sql_confidence, current_mood) rbi-postgres-demo::DATABASE-> VALUES (28, 'Caplan', 'Alexandra', 5, 'Happy'); INSERT 0 1 rbi-postgres-demo::DATABASE=> Select avg (age) from bootcamp)people; Select last_name from bootcamp_people where age <30; Select from bootcamp_people where first_name ILIKE ‘%han’; Select From bootcamp_people Where first_name
Can also do counts, averages etc: Select count(id) where mood = ‘Happy’;
Getting in sql: Pg - links to posgress Lets us write sequel
How to create tables for our data? CREATE TABLE. How to create incrementing id - id SERIAL PRIMARY KEY, If we don't want them to be zero characters, we can put NOT NULL
db.query(
CREATE TABLE tasks( id SERIAL PRIMARY KEY, description VARCHAR(128) NOT NULL, completed BOOLEAN NOT NULL DEFAULT FALSE );
)$1 can stop people putting malicious sql somewhere
Get tasks - when the user asks for the task Postman asks api, which asks database, api responds with a json representation.
When you make something await, you need to make the function asynchronous!
Object.entries - you get an array - first thing is key, second thing is value
To connect to Heroku, pass a connection string to the argument variable in the Pool command.{connection string: process.env.DATABASE_URL });