Hello. I'm trying to figure out how to do the equivalent of of a query populate() process in Mongoose in Retool.
I currently have a MongoDB database with two collections (profiles and tags). I reference the tags id's in an array in the profiles collection records. I'd like to be able to populate the data from the tags collection when I query the profiles collection. I thought maybe it would be possible with $lookup in MongoDB, but everything I've tried has failed. Is it possible to do this in Retool?
Here is an example of a record in the profiles collection:
{
"_id": {
"$oid": "622ba229ff3c86683a1fae8f"
},
"tags": [{
"$oid": "603f35613534cc9390498ce1"
}, {
"$oid": "603f35613534cc9390498ce2"
}],
"name": "Tom Kundig",
"createdAt": {
"$date": {
"$numberLong": "1614755169845"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1614755169845"
}
},
"__v": {
"$numberInt": "0"
}
}
Here is an example of a record in the tags collection:
{
"_id": {
"$oid": "622ba3f4ff3c86683a1fae90"
},
"name": "Architect",
"slug": "architect",
"__v": {
"$numberInt": "0"
},
"createdAt": {
"$date": {
"$numberLong": "1614755241653"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1615147104584"
}
}
}
Here is what I'd like the record returned to look like:
{
"_id": {
"$oid": "622ba229ff3c86683a1fae8f"
},
"tags": [{
"_id": {
"$oid": "603f35613534cc9390498ce1"
},
"name": "Architect",
"slug": "architect",
"__v": {
"$numberInt": "0"
},
"createdAt": {
"$date": {
"$numberLong": "1614755241653"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1615147104584"
}
}
}, {
"_id": {
"$oid": "603f35613534cc9390498ce2"
},
"name": "Modern",
"slug": "modern",
"__v": {
"$numberInt": "0"
},
"createdAt": {
"$date": {
"$numberLong": "1614755241653"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1615147104584"
}
}
}],
"name": "Tom Kundig",
"createdAt": {
"$date": {
"$numberLong": "1614755169845"
}
},
"updatedAt": {
"$date": {
"$numberLong": "1614755169845"
}
},
"__v": {
"$numberInt": "0"
}
}
Any help or guidance is appreciated. Thanks.