Anyone can help me please, i want to combine the query firestore using node js and firebase-admin, this is like sql join. i try with this code and this doesn't work well, is there any other away ?
let projects = [];
snapshot = await db.collection("project").get();
snapshot.forEach((doc) => {
projects.push({
id: doc.id,
...doc.data(),
project_airdrop: [
db
.collection("project_airdrop")
.where("project_id", "==", doc.id)
.get()
.then((values) => {
return values.forEach((val) => val.data());
}),
],
project_minting: [
db
.collection("project_minting")
.where("project_id", "==", doc.id)
.get()
.then((values2) => {
return values2.forEach((val2) => val2.data());
}),
],
});
});
the result is not what i expected
{
"status": "success",
"data": [
{
"id": "Qs0XhpRQtTYhstSaNiGC",
"twitter": "https://www.twitter.com/",
"slug": "persiano-gelato-and-bar",
"status": "ongoing",
"supply": "suppliers",
"discord": "https://discord.gg/cuEnDuXp/",
"website": "https://www.google.com/",
"url_image": "test123456",
"desc": "lorem ipsum dolor sit daily hard working",
"title": "Persiano Gelato and Bar",
"project_airdrop": [
{} // <-- i expected the data is showed
],
"project_minting": [
{} // <-- i expected the data is showed
]
}
]
}
i expected the result is showed