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.
- 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 navigation bar
- Part 5: Start with the date picker
- Part 6: Add the sidebar
- Part 7: Add react-day-picker
- Part 8: Add the calendar to the page
- Part 9: Configure the DayPickerInput component
- Part 10: Sync the start and end dates
- Part 11: Show the price for the chosen dates
- Part 12: Login and signup forms
- Part 13: Activate the modal
- Part 14: Send registration data to the server
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.
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
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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.