Mattéo
Mattéo
Explore posts from servers
PPrisma
Created by Mattéo on 6/18/2024 in #help-and-questions
Multiple relation between models
Hello guys, I'm creating a marketplace but I have a problem. I have 2 models: User and Post. I want the user to have the fields posts (his own posts) and favoritePosts (the posts he liked). I made this but it doesn't work:
model User {
id String @id @default(cuid())
firstName String
lastName String
email String @unique
phone String @unique
password String
verificationCode String?
posts Post[]
favoritePosts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}

model Post {
id String @id @default(cuid())
slug String
title String
description String
price Int
images String[]
reports Report[]
userId String
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model User {
id String @id @default(cuid())
firstName String
lastName String
email String @unique
phone String @unique
password String
verificationCode String?
posts Post[]
favoritePosts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}

model Post {
id String @id @default(cuid())
slug String
title String
description String
price Int
images String[]
reports Report[]
userId String
user User @relation(fields: [userId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
Can you help me please ?
6 replies
DIAdiscord.js - Imagine an app
Created by Mattéo on 7/21/2023 in #djs-questions
How to get last messages from a text channel ?
Hello, I would like to get messages from the newest to the oldest in a text channel. My way to get the oldest:
const oldestMessages = await <GuildText>.messages.fetch({ limit: 100 });
const oldestMessages = await <GuildText>.messages.fetch({ limit: 100 });
But how to get the newest ? Thanks guys
14 replies