[SOLVED] How to exclude already queried items with useMoralisQuery?

Hey guys,

I’m currently making two different (but similiar) queries to the same table in my database as follows:

  const { data: whoopyP2a, isFetching: fetchingWhoopyP2a } =
    useMoralisQuery(
      "CreatedWhoopys",
      (query) => query.equalTo("creatorAddress", "0xDD8C868Ee486e2D0778b7c174917a15ce2a4530A").limit(limit).descending("updatedAt"),
      {
        live: true,
      }
    );

  const { data: listedWhoopys, isFetching: fetchingListedWhoopys } =
    useMoralisQuery(
      "CreatedWhoopys",
      (query) => query.limit(limit).descending("updatedAt"),
      [limit],
      {
        live: true,
      }
    );

Is there any way I can exclude the items in whoopyP2a from the data returned in listedWhoopys? They are both queries from the same table.

Thanks!

You could filter it out manually in your code or make another query that excludes any objects that has that creatorAddress.

1 Like

you can try query.select syntax to specify what to include

1 Like

I did this:

query.matches("players", address || '', 'i').limit(100).descending("updatedAt").notContainedIn("creatorAddress", ["0xDD8C868Ee486e2D0778b7c174917a15ce2a4530A"]),

Works perfectly!

1 Like