I am updating a document in firebase when user enters a comment.The code for the same is:
const docRef=collection(db,"posts",post.id);
console.log(docRef);
updateDoc(docRef,{
user:localStorage.getItem('Name'),
title: post.title,
comment:temppost ,
upVotesCount: 0,
downVotesCount: 0,
createdAt: post.createdAt,
updatedAt: date.toUTCString(),
isCommentVisible:false
});
But I m getting this error:
Uncaught (in promise) FirebaseError: Invalid collection reference. Collection references must have an odd number of segments, but posts/PQAvoGjUeX8aPVVZxMNC has 2.
I haven't used any subcollections here.