Pipeline help - Left Outer Join style

I have 2 tables:

NFT

  • Id
  • Name
  • etc…

Offers

  • Price
  • NFT (Pointer)

I want to run a query for a list of NFT objects, but also include the first related Offer for the corresponding NFT object…such as:

{
   Id: "NFTId",
   Name: "My NFT",
   Offers: [
        {
            Price: 200
        }
    ]
}

Is this possible using pipelines?

I have tried to use a lookup, but can’t seem to get any results back inside the Offers array.

I don’t know exactly what you need, it looks like you have that NFT pointer there in Offers table.

Yes i have a pointer in the offers table to the NFT.

But i want to return some search results for NFT’s, but also include the Offer.

There could potentially be multiple Offers for each NFT, ideally i just want the first one, but all would be fine too.

I don’t know if you can do it with a pipeline, you could do it with more than 1 query.

Yeah thats what i am trying to do now.

How would i query on the Offers table. I am thinking to use the ContainedIn filter and pass in the NFT ids.

But getting 0 results:

const query2 = new Moralis.Query("Offers");
query2.containedIn("NFT", ids)
var offers = await query2.find({useMasterKey: true});

Where the ids is an array of the NFT objectId

If you don’t have too many entries in the Offers table, then you could get all the list of offers and parse it after that.

it should be possible to do what are you trying to do there with a list of IDs.