Reputation: 71
I can't get any output in console, I want to sync 'title' to 'asdasd' which I want to do.
async function getPost (){
const li = [];
const storeDb=firebase.firestore()
const postDetailsRef = collection(storeDb,'Post');
const postQuery = query(postDetailsRef,where('title', '==','asdasdt'));
const querySnapshot = await getDocs(postQuery);
querySnapshot.forEach((doc)=>{
console.log('hop doc',doc.data())
})
}
Upvotes: 0
Views: 157
Reputation: 111
I tried this with my firestore and it's working properly
const db = getFirestore(firebaseApp);
const test = query(collection(db, 'development', data.id, 'messages'), where('index','==', 1));
const testSnapshot = await getDocs(test);
testSnapshot.docs.map(doc =>
{
console.log( doc.data())
});
because you are using getDocs
and query
, i assume you use modular firebase v9. Try changing
const storeDb=firebase.firestore()
to
const storeDb = getFirestore(yourfirebaseApp);
according to this firebase document
Upvotes: 1