Solution: Postgres and Deno
Go over the solution to the Postgres and Deno challenge.
We'll cover the following...
We'll cover the following...
To solve this challenge, we need to follow the three steps given below.
Step1: Establishing a Postgres connection
First, we need to establish a Postgres connection and create the required table for the Car
entity:
import { Client } from "https://deno.land/x/postgres/mod.ts";const client = new Client({user: "postgres",database: "postgres",hostname: "localhost",port: 5432,});await client.connect();// Create table carsawait client.queryArray("CREATE TABLE Cars(id SERIAL PRIMARY KEY, model varchar(255), registration varchar(255));");
Explanation
- Lines 3–8: We define the Postgres connection.
- Line 10: We connect to the Postgres database.
- Line 13: