As in the title, I want to show only documents with matching fields in Firebase.
Now my code using jquery looks like this:
const db = firebase.firestore();
db.collection('product').get().then((product)=>{
product.forEach((doc)=>{
var li = "";
console.log(doc.data())
if(topic == doc.data().topic){
li = `
<div>
<img class="${img}" src="${doc.data().img}">
<p class="text-500 text-white">${doc.data().title}</p>
</div>
`
}else{
li = `
<div>
<img class="${img}" src="${doc.data().img}">
<p class="text-500 text-white">${doc.data().title}</p>
</div>
`
}
$(`.app`).append(li)
})
});
<div class="app"></div>
All documents are now available. For example, if the current URL is "https://example.com?topic=firebase", I want to display only the contents of the documents with the topic field firebase in the documents in a collection called product.
Thank you in advance.