How to INNER JOIN two Objects

Hello,

I’ve read through the docs but am not able to see how we can “inner join” 2 object stores in a query.

For example, we have 2 independent object stores - DataSets and DataOrders:

DataSets have:
id, colA, colB

DataOrders have:
id, DataSetID, colX, colY

I’d like to write a single query to join DataSets onto DataOrders via the “DataOrder.DataSetID == DataSet.id”

so I can get a full result set:
DataSet.id, colA, colB, DataOrder.id, DataSetID, colX, colY

Also - we are using React Moralis - https://github.com/MoralisWeb3/react-moralis#usemoralisquery

Any help will be appreciated.

Thanks,

Check this: https://docs.moralis.io/moralis-sdk/queries#lookup-join

Let me know if the docs help you

Thanks @ivan - that worked.

My original question should not have mentioned INNER JOIN as that’s not correct. Should be “how can I JOIN 2 data object collections”

Also for anyone else trying to JOIN on the ID field from one object to another property field of another Object (as per my example above “DataOrder.DataSetID == DataSet.id”)

You need to use the field “_id” in your pipeline
e.g.
foreignField: “_id”

Full example here:

2 Likes