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

213
Views
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 answers
Answer question

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 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!