Query property values of included pointer objects

I am trying to use the query constraint “equalTo” on a query which includes pointed documents but I dont get any results back no matter how I try it. What is the correct way of doing it?

  query.include("dex");
      query.include("token0");
      query.include("token1");
      query.include("token0_ticker");
      query.include("token1_ticker");
  query.equalTo("token0.attributes.symbol", this.search.toUpperCase());

I dont get any data back, I tried equalTo(“token0.symbol”) / equalTo(“token0.attributes.symbol”)

When I leave out the equalTo part and just fetch all, the result documents have the token0 documents included with all their attributes.

try to also use query.select, not sure if it helps

maybe the value for that equalTo is not the right one, you can try with another field and with a hardcoded value first as parameter

I’m not sure what token0 is meant to be but with your equalTo if you’re trying to target object keys, that won’t work as it’s just a static string. You would remove the quotes here.

the values I am passing in are correct I logged them already. What is the difference when using include even? I left include away and still had the pointer objects. When I use select, all the other properties would be missing from what I understand or I would have to select every single property and all pointers properties as well

token0 is a nested document, its a pointer for some other class and has its own properties

did you try with include/select with the complete nested path: token0.attributes.symbol ?

I have query.include(“token0”) in usage and also did this which doesnt have any affect either

 if (this.search.length > 0) {
        query.select("token0")
        query.equalTo("token0.attributes.symbol", this.search.toUpperCase()); //no results
        //query.equalTo("token0.symbol", this.search.toUpperCase()); no results
      }

I mean to try to use the complete path in include/select that you use for equal to.
All this syntax is from parse server.

I tried any possible combination and none is making any difference.

I tried include(“token0.attributes.symbol”)
.include(“token0.symbol”)

in combination with equalTo(“token0.attributes.symbol”) and equalTo(“token0.symbol”)

nothing works.

When I log the query it has this inside the where property

image

I came up with a solution which works but is pretty verbose. Let me know if there are other ways than this please.

   if (this.search.length > 0) {
        const symbolQuery = new Moralis.Query("TokenMetaData");
        symbolQuery.equalTo("symbol", this.search.toUpperCase());
        const symbol = await symbolQuery.first();
        query.equalTo("token0", {
          __type: "Pointer",
          className: "TokenMetaData",
          objectId: symbol.id
        });
      }

it looks like second solution with matchesQuery works too

1 Like