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

323
Visualizações
In TypeORM, how do I get raw data in a structurerd format?

This is my model. There's a many-to-many relationship between user and post.

ER Diagram

My current querybuilder:

getRepository(Post)
    .createQueryBuilder("post")
    .innerJoinAndSelect("post.creator", "user")
    .select(["post.id", "post.content", "post.createdAt", "user.id", "user.username", "user.avatar"])
    .orderBy("post.createdAt", "DESC")

Results:

[{
    id: 18,
    content: "I'm Ana.",
    createdAt: "2021-11-09T04:06:48.931Z",
    creator: {
        id: 31,
        username: "ana",
        avatar: "https://avatars.dicebear.com/api/female/ana.svg"
    }
}]

I want to add another field "liked", a boolean value telling me if the logged-in user has liked the post. I could use getRawMany, but the json would be completely flat, and I don't want to destroy the current API format. Is there a way I can get the best of both worlds?

about 4 years ago · Juan Pablo Isaza
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