Hi there,
I am running the following aggregate query on cloud function.
const pipeline = [
{
match: {
$expr: {
$and: [
{ $eq: ["$objectId", someId] }, {
$gt: ["$_created_at", { $toDate: someDateParam }],
},
],
},
},
},
{
lookup: {
from: "Profile",
localField: "wallet",
foreignField: "wallet",
as: "profile",
},
}
];
const query = new Moralis.Query("SomeMembersTable");
const res = await query.aggregate(pipeline);
The query returns the result which is fine.
However one of the issue is that profile
field in the result is an array. I know it is a join query. Is there anyway to make it return only one item.
The second question is in the profile
I would expect an image url to be returned as profile.image
. The image field saved on Profile
table is a File type.
Anyway I could achieve this?
Thanks