So here is the request to get some data from Firestore with vanilla JS.
const q = query(collection(db, "tasks"), where("userId", "==", "Milos"), where("archive", "==", "false"));
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
// doc.data() is never undefined for query doc snapshots
console.log(doc.id, " => ", doc.data());
});```
With this request, I get a from collection tasks where userId equals "specificname", and where the archive field is equal to false. So with this request, I will get full tasks, is there some way with Firestore to get only a specific field or fields, not a full task with all fields? Is something even possible with Firestore or do I need to parse this object on the front side?
No, you cannot retrieve partial responses from Firestore on the client. Every request will always return all documents to the client. This also means you cannot protect certain fields in a document.
Server-side you could try using Query.select.
let collectionRef = firestore.collection('col');
let documentRef = collectionRef.doc('doc');
return documentRef.set({x:10, y:5}).then(() => {
return collectionRef.where('x', '>', 5).select('y').get();
}).then((res) => {
console.log(`y is ${res.docs[0].get('y')}.`);
});