Skip to content

Instantly share code, notes, and snippets.

View CodebyOmar's full-sized avatar

Umar Abdullahi CodebyOmar

View GitHub Profile
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
@CodebyOmar
CodebyOmar / main.go
Last active February 10, 2019 19:29
package main
import (
"log"
"net/http"
"tutorial/3factor-chatapp/notifications"
"tutorial/3factor-chatapp/rooms"
"github.com/joho/godotenv"
)
@CodebyOmar
CodebyOmar / fn.go
Last active February 18, 2019 14:18
Entry function for the addToRooms cloud function
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=
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
@CodebyOmar
CodebyOmar / fn.go
Last active February 18, 2019 14:58
package notifications
import (
"fmt"
"io/ioutil"
"net/http"
"os"
s "strings"
"github.com/Jeffail/gabs"