OR-ed Query operator with Pointer Class Data

I’m having a problem to query data with Pointer class using OR-ed Query Constraints.

                const projQuery = new Moralis.Query("Transactions");
                const hashQuery = new Moralis.Query("Transactions");
                const fromQuery = new Moralis.Query("Transactions");
                const usernameQuery = new Moralis.Query("Transactions");

if (search.length > 0) {

                    hashQuery.matches("hash", search, "i");

                    fromQuery.matches("from", search, "i");

                    const projectQuery = new Moralis.Query("Project");

                    projectQuery.matches("name", search);

                    const project = await projectQuery.find();

                    if (project.length > 0) {

                        projQuery.equalTo("project", {

                            __type: "Pointer",

                            className: "Project",

                            name: project[0].get("name")

                        });

                    }

                    const spotsQuery = new Moralis.Query("Spots");

                    spotsQuery.matches("username", search);

                    const spot = await spotsQuery.find();

                    if (spot.length > 0) {

                        usernameQuery.equalTo("spots", {

                            __type: "Pointer",

                            className: "Spots",

                            discord: spot[0].get("username")

                        });

                    }

                }

const mainQuery = Moralis.Query.or(hashQuery, fromQuery, usernameQuery, projQuery);

Without the Pointer class data, hashQuery and fromQuery works correctly, however after I add Pointer class Project and Spots, the query returns all the data without filtering it.

What am I missing in this case, please?

@cryptokid Any help here?

1 Like

can you try to run this separately to see if it works as expected?