Prisma Model Coming Undefined ! Next Js and Neon Db

Hello Guys,

This is my first time here, i need your help guys.

I never tried Prisma this is my first time please help me out.

this is my prisma schema

model Message {
  id String 
  content String 

  fileUrl String?

  memberId String

  member Member 

  channelId String

  channel Channel 



  index([channelId])
  index([memberId])
}


model Conversation {
  id String 

  memberOneId String

  memberOne Member relation("MemberOne", fields: [memberOneId], references: [id], onDelete: Cascade)

  memberTwoId String

  memberTwo Member relation("MemberTwo", fields: [memberTwoId], references: [id], onDelete: Cascade)

  directMessages DirectMessage[]

 

}

model DirectMessage {
  id String 


  content String 

  fileUrl String?

  memberId String

  member Member relation(fields: [memberId], references: [id], onDelete: Cascade)

  conversationId String
  conversation Conversation relation(fields: [conversationId], references: [id], onDelete: Cascade)


}

i was following tutorial and in the middle of that i come to this error and it been 2 hours I am not able to fix this.

Error

Error: Cannot read properties of undefined (reading 'findFirst')
ser.development.js:2262:17)



Error: Cannot read properties of undefined (reading 'findFirst')
    at findConverstation (conversation.ts:19:40)
    at getConversation (conversation.ts:9:12)

Error: Cannot read properties of undefined (reading 'create')
    at newConversation (conversation.ts:48:34)
    at getConversation (conversation.ts:12:26)

The Code behind error

const cont = await db.conversation.findFirst({
      where: {
        AND: [{ memberOneId: memberOneId }, { memberTwoId: memberTwoId }],
      },
      include: {
        memberOne: {
          include: {
            profile: true,
          },
        },
        memberTwo: {
          include: {
            profile: true,
          },
        },
      },
    });




await db.conversation.create({
      data: {
        memberOneId: memberOneId,
        memberTwoId: memberTwoId,
      },
    });

help me out guys

I am using Next Js and Neon Db

If you’re using Next I think you’ll have better success asking in a NextJs community :slight_smile: