CodeNewbie Community 🌱


Posted on • Updated on

Make a chat app with Node JS

I want to make a chat app with react, node,, and Prisma. I am unable to add direct message (dm) functionality but added group functionality.

My Schema

datasource db {
  url      = env("DATABASE_URL")
  provider = "postgresql"

generator client {
  provider = "prisma-client-js"

model User {
  id        Int      @id @default(autoincrement())
  createdAt DateTime @default(now())
  email     String   @unique
  username  String
  password  String
  sender    Messages @relation("sender")
  receiver  Messages @relation("receiver")

model Group {
  id        Int        @id @default(autoincrement())
  messages  Messages[]
  user      Users[]

model Messages {
  id          Int     @id @default(autoincrement())
  text        String 
  group       Group   @relation(fields: [groupId], references: [id])
  groupId     Int
  sender      User    @relation("sender", fields: [senderId], references: [id])
  senderId    Int
  reciever    User    @relation("reciever", fields: [recieverId], references: [id])
  recieverId  Int
Enter fullscreen mode Exit fullscreen mode

Top comments (0)