containedIn querying: arrays & objects

Is there any way to do containedIn queries on objects? or is it locked to arrays?

Code example provided. The “ItemsInPlay” table lists both Items & Things columns as objects.

 const query = new Moralis.Query("Thing");
   query.equalTo("isPublished" , true);
   query.greaterThanOrEqualTo("thisDate", new Date() );

   const  thingList = await query.find(); // This gets an list of things that have a date set greater than now

   const query2 = new Moralis.Query("Items");
   const itemObject = await query2.find(); // This gets a list of awesome item objects
   const query3 = new Moralis.Query("ItemsInPlay");
   query3.containedIn("item", itemObject);
   query3.containedIn("thing", thingList);

This is what I’d like to do as the “ItemsInPlay” table columns only lists what I need in object form, if at all possible.

Hi, that table also has an object_id?

The “ItemsForSale” has both “item” and “thing” columns as pointer types. So they reference the entire “item” object & “thing” object on each row.

I’m curious how those pointers look then.

Here’s a screenshot of the ItemsForSale table for reference

Those strings saved as pointer look like an objectId found in destination table.

Pointers are stored as objects in Parse database, so if you try to compare a string to an object with query.equalTo() function, nothing will be found. This is how pointers are stored:

    __type: 'Pointer',
    className: '_User',
    objectId: user-object-id

So what is the way forward to do containedIn or matchQuery or equivalents of matching a list of objects referenced as pointers in another table in Moralis?

If we knew you would already have the answer, did you read that link I posted and tried this?

If you are querying a class with pointers and want your result comes with the whole object nested, you should set this in your query:

var query = new Parse.Query('Pictures');
1 Like