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

220
Visualizações
FIRESTORE | How to fetch creator doc with creator_id in multi posts

I'm a newbie to try firestore .In javascript (vue) i fetched multi posts doc from firestore

How do I retrieve data from another collection by id? when i use creator_id to fetch creator collection from author function it will be Promiss or underfild alert from return

db.firestore().collection.collection("articles")
    .where("status", "==", 1)
    .orderBy("time","desc")
    .get()
    .then(snap => {
      snap.forEach(doc => {
        var post = {};
        var article = doc.data();
        post.id = doc.id;
        post.creator = article.creator_id
        ----- data ----
        this.posts.push(post);
      });

output : [{id:"",txt:"",creator_id:"this id i will use it"},{},{},{},...]

From this code I need to retrieve the creator document with the creator_id. And I think I'll do the same with the repiles doc from comments doc. I don't know if it's a good idea. If you will recommend me

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Firestore (like many NoSQL databases) does not support server-side joins (like you have in SQL databases).

If you want to display information for each user next to their comment (say, their name), you have two main options.

  • Either you load each user in your application code, often referred to as a client-side join. This is not as slow as you may think, but you'll want to make sure you optimize it properly (for example, by not loading the same user information over and over).
  • Or you ensure the information you need is already present in each comment document, so you duplicate the user's name in there. If you come from a SQL background this may seem like blasphemy, but it is actually quite idiomatic in NoSQL databases. In fact, it is part of the reason they can scale to so many read operations.

If you're new to this topic, I recommend checking out:

  • NoSQL data modeling, a primer on modeling data in many NoSQL databases.
  • Getting to know Cloud Firestore, a video series walking through many data modeling and code scenarios.
  • Firebase data structure and url
  • What is denormalization in Firebase Cloud Firestore?
  • How to write denormalized data in Firebase
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