Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda