Hello! Im my project im working with mongo database. There I have a Payments collection as follows:
"payments" : [
{
"_id" : ObjectId("614c7daa61490a8940fa550d"),
"amount" : 35,
"transactions" : [
"614c7daa61490a8940fa550b",
"614c7daa61490a0080fa550a",
],
}
],
Within the payments field is the transactions field that contains the transaction ids corresponding to the transaction collection. I would like to be able to link those ids and take me to the corresponding transaction but since this field is of type [‘string’] I can’t achieve the objective.
Is there any way to achieve the goal? I thought about maybe making a smart collection where I create objects each one with a transaction, that is to say, starting from the json data shown above obtain:
"payments" : [
{
"_id" : ObjectId("614c7daa61490a8940fa550d"),
"amount" : 35,
"transactions" : [
"614c7daa61490a8940fa550b",
],
}
],
"payments" : [
{
"_id" : ObjectId("614c7daa61490a8940fa550d"),
"amount" : 35,
"transactions" : [
"614c7daa61490a0080fa550a",
],
}
],
but I haven’t really been able to get it to work.
I appreciate any help!
Thank you!