Hi all! Good times when I use to write just one line with SQL and get the job done! Now Iām facing a hard time with mongodb. The problem may look simple for some people, but I simply need to to do the following:
I got a collection called PlacedOfferings and another collection titled as ClosedOfferings. Iām not sure if Iām doing this the right way but all that I need is to look for the column OfferingId at the ClosedOfferings and see if the OfferingId is present. If so the Offering is closed, if not the offering is open and it should be rendered at the userās dashboard front end. I tried so many approuches but I always get an sintax error or the wrong output.
I know the code bellow is wrong but Iāll put it here only in order to give you a better idea of what I expect:
Moralis.Cloud.define(āgetOpenOfferingsā, async (request) => {
const query = new Moralis.Query(āPlacedOfferingsā);
const pipeline = [
{
lookup: {
from: "ClosedOfferings",
localField: "OfferId",
foreignField: "OfferingId",
let: {Offering:"$OfferingId"},
pipeline: [{
match:{ OfferingId, null },
}],
as: "offers",
},
},
];
return await query.aggregate(pipeline);
})
Iāve tried the same code with or without $, $$, āā, etc, etc, etc Oh my gosh! It use to be so easy with SQLā¦
I appreciate any code to help me solve this simple problem.