Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Latest commit

 

History

History
57 lines (52 loc) · 1.39 KB

File metadata and controls

57 lines (52 loc) · 1.39 KB

This was run using npm pg library to create the database users

// create database and `users` table
const query = `
CREATE TABLE users (
    fname varchar,
    lname varchar,
    mobile bigint,
    email varchar,
    publicID varchar,
    privateID varchar,
    dob date
)`

client
.query(query)
.then(res => {
    console.log('Table is successfully created');
})
.catch(err => {
    console.log("Already exists")
    console.error(err);
})
.finally(() => {
    client.end();
})

This was run to add auto incrementing primary key row to existing users table

ALTER TABLE users ADD COLUMN id SERIAL PRIMARY KEY;

This Postgres command was run to create the relational table messages for the users table

CREATE TYPE message_status AS ENUM ('waiting', 'synced', 'delivered');

CREATE TABLE messages (
    id SERIAL PRIMARY KEY,
    sender INTEGER REFERENCES users(id),
    receiver INTEGER REFERENCES users(id),
    message TEXT NOT NULL,
    timestamp TIMESTAMP NOT NULL,
    status message_status NOT NULL
);

History

  • ...
  • Message saved to server DB
    • Redirects to a page that executes client.js
      • Client.js contains code for writing to indexedDB
    • Worker displays notification

  • create client fetch syntax for sending requests using jwt embeded header

  • How do I access and store jwt token using only client side javascript static requests