Airbnb clone, add postgres

This post is part of a new series where we build a clone of Airbnb with Next.js. See the first post here.

Part 1: Let’s start by installing Next.js
Part 2: Build the list of houses
Part 3: Build the house detail view
Part 4: CSS and …


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

This post is part of a new series where we build a clone of Airbnb with Next.js. See the first post here.

In this lesson we’re going to set up the database. We’re going to use Postgres.

See my introduction to Postgres.

You can install it locally on the computer, but I’m going the simplest route and use Railway https://railway.app.

See how to install PostgreSQL on macOS

Railway provides a super easy setup and a nice free plan.

Once you’re logged in, click provision PostgreSQL:

Then click PostgreSQL in the sidebar and the Connect tab to show the connection credentials:

We’re also going to create the first table, to host our users data.

Now in the Query tab you can enter any SQL query.

See my introduction to SQL

Now we’re going to create a new table using SQL.

Use this syntax:

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  email VARCHAR(255) UNIQUE NOT NULL,
  password VARCHAR(255) NOT NULL,
  session_token VARCHAR(255),
  session_expiration TIMESTAMP
);

Now you will have the table in the system:


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2021-12-15T05:00:00+00:00) Airbnb clone, add postgres. Retrieved from https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/

MLA
" » Airbnb clone, add postgres." flaviocopes.com | Sciencx - Wednesday December 15, 2021, https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/
HARVARD
flaviocopes.com | Sciencx Wednesday December 15, 2021 » Airbnb clone, add postgres., viewed ,<https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/>
VANCOUVER
flaviocopes.com | Sciencx - » Airbnb clone, add postgres. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/
CHICAGO
" » Airbnb clone, add postgres." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/
IEEE
" » Airbnb clone, add postgres." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/. [Accessed: ]
rf:citation
» Airbnb clone, add postgres | flaviocopes.com | Sciencx | https://www.scien.cx/2021/12/15/airbnb-clone-add-postgres/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.