CodeNewbie Community

loading...

Make a chat app with Node JS

zakiAzfar
Updated on ・1 min read

I want to make a chat app with react, node, socket.io, 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

Discussion (0)