Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
Creating a schema with minified version of a type

How can I create a Prisma schema for mongoDb that contains sort of a minified version of another object?

To explain better the data I am working with could look something like this:

const basicUser = {
  id: "62091d9ae17cad32fbe0eda5",
  displayName: "John Smith",
};
const post = {
  title: "My Title",
  content: "My content",
  author: basicUser,
};

const user = {
    id: "62091d9ae17cad32fbe0eda5",
    firstName: "John",
    lastName: "Smith",
    displayName: "John Smith",
    emailAddress:"john@test.com"
}

I am not interested in creating relations as I just want to include this basic data and then to be able to look up the full user if I need to.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Prisma has released support for composite types (Known as Embedded Documents in MongoDB) for embedding documents inside documents.

From your use case, it seems that composite types should be helpful to you.

You can define basicUser as a type and reference it in your post model.

type basicUser {
  id          String
  DisplayName String
}
model Post {
  title   String
  content String
  author  basicUser
}

Reference for using composite types.

Please note that this feature is in preview and you need to be on version 3.10.0 or later.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!