Getting a weird thing where Prisma 2.0 PrismaClien...
# orm-help
l
Getting a weird thing where Prisma 2.0 PrismaClient is returning objects for a 1:many relationship query rather than the data. I introspected a mySQL database to generate my schema than annotated it.
index.js
Copy code
const { PrismaClient } = require("@prisma/client")

const prisma = new PrismaClient()

async function main() {
  const allOrganizations = await prisma.organizations.findMany({
    include: {
      profiles: true
    },
  })
  console.log(allOrganizations)
}

main()
  .catch(e => {
    throw e
  })
  .finally(async () => {
    await prisma.disconnect()
schema.prisma
Copy code
// Organizations and their relations

model Organizations {
  id         Int      @default(autoincrement()) @id
  updatedAt  DateTime
  createdAt  DateTime
  name       String?
  type       Int?
  phone      String?
  email      String?
  locationId Int?
  // manually encoded 1:1 relation, FK on source
  location   Locations? @relation(fields: [locationId], references: [id])
  // manually encoded 1:n relation, FK on target
  profiles   Profiles[] 
}

// Profiles and their relations

model Profiles {
  id                   Int      @default(autoincrement()) @id
  createdAt            DateTime
  updatedAt            DateTime
  memberIdentification String?
  photo                String?
  // note: is JSON type in database
  requirementsStatus   String?
  classificationId     Int?
  organizationId       Int?
  payscaleId           Int?
  personId             Int?
  // manually encoded 1:1 relation, FK on source
  classification       Classifications?  @relation(fields: [classificationId], references: [id])
  organization         Organizations?    @relation(fields: [organizationId], references: [id])
  payscale             Payscales?        @relation(fields: [payscaleId], references: [id])
  // alias People as 'contact'
  contact              People?           @relation(fields: [personId], references: [id])
  // manually encoded n:m relation, FK on join table ProfileCertifications
  certifications       Certifications[]  @relation(name: "ProfileCertifications", references: [id])
  // manually encoded n:m relation, FK on join table JobLogs
  jobs                 Jobs[]            @relation(name: "JobLogs", references: [id])
}
Eager loading the other way works just fine
Same thing happening on many:many relations
Hmmm the data is there if I JSON.stringify the response
r
Hey @Louis Gelinas 👋 Are you using
console.log
?
l
... this is extremely embaressing.
Yeah I figured that out about an hour after dropping this message lol.
👍 1
r
No worries 🙂