xxxxxxxxxx
const q = query(collection(db, 'guides'), orderBy('timeStamp'));
onSnapshot(q, (querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(JSON.stringify(doc.data()));
});
});
xxxxxxxxxx
const getComments = async (parentId, slug, type, limit) => {
const db = firebase.firestore();
let commentsQuery = db.collection('comments3')
.where('postType', '==', type)
.where('postId', '==', slug)
.where('parentId', '==', parentId || null)
.orderBy("createdAt");
if (limit) {
commentsQuery = commentsQuery.limit(limit);
}
return commentsQuery.get();;
}