I am writing supporting method in firebase function. I need to get only random company name from the companies collections rather the given company where I getting only first value from the collection.
Any suggestion would be helpful.
async function selectCompany(companyName) {
const vouchercompany = [];
try {
await db.collection('companies')
.where('companyName', '!=', companyName)
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
vouchercompany.push(doc.data())
})
})
return vouchercompany;
} catch (error) {
json(error.message)
}
}