Array field in Parse.object always returns undefined

I’m adding a field to an array field like this:

const query = new Parse.Query(UsersPrivateDataTable);
query.equalTo("userID", user.id);
const entry = await query.first({ useMasterKey: true });

entry.add("linkedAddresses", lowerCaseAddress);

try {
  await entry.save(null, { useMasterKey:true });
} catch(error) {
  throw "Failed to save.";
};

I check the dashboard and the value was added to the array.

However when I try to get that object in the client, every field gets downloaded except that array field (linkedAddresses).

let query = new Parse.Query("UsersPrivateData");
query.equalTo("userID", user.id);
sub = await query.subscribe();
let result = await query.first();

result.get("linkedAddresses"); // RETURNS -> undefined
console.log(JSON.stringify(result)) // Prints all fields except "linkedAddresses"

However, if I add something to that array my sub.on('update') updates the object and I can see all the array.

Why can’t I access that field with a query? And why does it work with sub.on(‘update’)?

do you have any special configuration to linkedAddresses? Maybe protected fields or a before find trigger? Would you mind to change let result = await query.first(); to let result = await query.first({ useMasterKey: true }); just in case?

1 Like

I completely forgot I had a beforeFind trigger on that class… :man_facepalming: Thank you as always and sorry for the dumb question :sweat_smile: