user (
id SERIAL PRIMARY KEY
username TEXT UNIQUE
push_token TEXT
last_seen timestamp with time zone
last_typed timestamp with time zone
date_created timestamp with time zone DEFAULT now() NOT NULL
)
room (
id SERIAL NOT NULL PRIMARY KEY
name TEXT NOT NULL
room_type TEXT NOT NULL
)
message (
id SERIAL NOT NULL PRIMARY KEY
"text" TEXT NOT NULL
username INT FOREIGN KEY REFERENCES user(username) NOT NULL
room_id INT FOREIGN KEY REFERENCES room(id) NOT NULL
"timestamp" timestamp with time zone DEFAULT now() NOT NULL
)
user_rooms (
id SERIAL NOT NULL PRIMARY KEY
user_id INT FOREIGN KEY REFERENCES user(username) NOT NULL
room_id INT FOREIGN KEY REFERENCES room(id) NOT NULL
)
BEGIN;
CREATE TABLE public.users (
id serial PRIMARY KEY,
username text UNIQUE,
push_token text NOT NULL,
last_seen timestamp with time zone,
last_typed timestamp with time zone,
date_created timestamp with time zone DEFAULT now() NOT NULL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
"tutorial/3factor-chatapp/notifications" | |
"tutorial/3factor-chatapp/rooms" | |
"github.com/joho/godotenv" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rooms | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
s "strings" | |
"github.com/Jeffail/gabs" |
DB_HOST=
DB_PORT=
DB_USER=
DB_NAME=
DB_PASSWORD=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package rooms | |
// Room is a model representation of our room table | |
type Room struct { | |
ID float64 | |
Name string | |
RoomType string | |
} | |
// UserRoom is a model representation of our user_rooms table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package notifications | |
import ( | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
s "strings" | |
"github.com/Jeffail/gabs" |
OlderNewer