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

172
Views
Firestore sub collection write with Modular Javascript V9

Here is my users collection, chats is a sub collection in users

users -
      -userID1
              -chats -
                     - chatID1
                            chatDetails
      -userID2
              -chats -
                     - chatID2
                            chatDetails

I want to update a document in chats, here is my code

export const setChatNewMessageAlert = async (user_id, chat_id, bool) => {
  const chatRef = doc(db, "users", user_id, "chats", chat_id);
  const update = {
    new_message: bool,
  };
  await setDoc(chatRef, update, { merge: true });
};

for some reason is giving me this ERROR FirebaseError: Invalid document reference. Document references must have an even number of segments, but users/I7Flqla5m9OWStsoWs4PL3ncbQV2/chats has 3

even though I have four segments.

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