Hi everyone!
I am using react-moralis
with the useMoralis()
hook and start it with in the context of a MoralisContext.
const { Moralis } = useMoralis();
// Some function context after render (called with onClick event)
async function fetchUsers() {
Moralis.start({
appId: process.env.NEXT_PUBLIC_APP_ID,
serverUrl: process.env.NEXT_PUBLIC_SERVER_URL,
masterKey: process.env.NEXT_PUBLIC_MASTER_KEY
})
const query = new Moralis.Query("_User");
const nUsers = await query.count({useMasterKey: true })
console.log(`Found ${nUsers} users`)
const users = await query.find({useMasterKey: true })
console.log(users)
}
Observation:
Received only the current logged in user.(#1)
Expectation:
Receive all users in the _User
collection.
Thank you for any hints on what went wrong.
- I noticed a
dangerouslyUseOfMasterKey
in the MoralisProvider. Is it required for use withMoralis.start({...opts})
, setting thedangerouslyUseOfMasterKey
in the provider alone did not help.
ps: It would be nice to be able to exercise administrative tasks in the development context without creating cloud functions for it. But if itβs not possible I assume the only way to achieve administrative tasks is either using moralis/node
as server side services or cloud functions?