i have a `User` table, each `User` can have multip...
# orm-help
p
i have a
User
table, each
User
can have multiple
FollowedBy
records (a many to many relation to other Users). I want to push a record (a notification) to each of the
FollowedBy
users of the current user if a certain action has been done.
Copy code
model User {
  id                Int     @id @default(autoincrement())
  email             String  @unique
  name              String
  user_name         String  @unique
  password          String
  movies            Movie[]
  notifications     Notification[]
  followedBy        User[]  @relation("UserFollows", references: [id])
  following         User[]  @relation("UserFollows", references: [id])
}

model Notification {
  id                Int     @id @default(autoincrement())
  link              String?
  movie_id          Int?
  message           String
  icon              String?
  thumbnail         String?
  user              User    @relation(fields: [userId], references: [id])
  userId            Int
  watched           Boolean
}
So I need a create function on the notification:
Copy code
createNotification: async (_, args, {req, res}) => {
    const notification = await prisma.notification.create({
      
    });

    return notification;
  },
What would be the best way to go through the list of
FollowedBy
users for the current user? (current user id is available on the req
req.userId
r
Answered your query on GH discussions 🙂