Expand examples of useMasterKey on docs

Hi everyone! I’m working with Moralis and I got a suggestion to documentation. It will be awesome if you could include more examples of how to use useMasterKey, there are some methods where you use it on the first parameter, like find(), and others on the second one, like save(), it’s confusing.



I didn’t see your aswer before, thank you ! On that example you use Moralis.Object.saveAll, where does objects come from?
Also it would be great if you could include the saveAll method on ‘Objects’ section of the docs

usually objects come from a previous query with find

I’m trying to run a get() query on the cloud and I get an error saying that the user needs to be authenticated. I was wondering if there’s a way to use MasterKey on a get query. I.e. query.get(id);
I tried this query.get({objectId:id, useMasterKey: true}) but it didn’t seem to work

I think that you could do that with a basic query: https://docs.moralis.io/moralis-server/database/queries#basic-queries

const Monster = Moralis.Object.extend("Monster");
const query = new Moralis.Query(Monster);
query.equalTo("ownerName", "Aegon");
const results = await query.find();
alert("Successfully retrieved " + results.length + " monsters.");
// Do something with the returned Moralis.Object values
for (let i = 0; i < results.length; i++) {
  const object = results[i];
  alert(object.id + ' - ' + object.get('ownerName'));


For the record, this eventually worked
query.get(id, { useMasterKey: true });

1 Like