rbi-learning / Today-I-Learned

1 stars 0 forks source link

08/13 Today I Learned #132

Open AlexandraCaplan opened 4 years ago

AlexandraCaplan commented 4 years ago

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 });