How to get User list?

I try to use this

    const User = Moralis.Object.extend("User");
    const query = new Moralis.Query(User);
    const results = await query.find();

But problem is Result return an array that have only one item ( Current user), for another user, It not showing on result array

This is my User table ( 5 item)


But in response array, I have only 1 item and It is current User login

1 Like

Hey @letieu8

This is because every user object has own ACL, so each user has access only for own user object.

You can create a cloud function like this and enable using of masterKey:

Moralis.Cloud.define("averageStars", async (request) => {
  const query = new Moralis.Query("User");
  const results = await query.find({ useMasterKey: true });
  return results;
});

https://docs.moralis.io/moralis-server/cloud-code/cloud-functions
https://docs.moralis.io/moralis-server/cloud-code/cloud-functions#using-the-master-key-in-cloud-code

1 Like