From following lots for random documentation ive managed to use Parse.Query client side which subscribes to my live query server
however i need to use masterKey but if were executing the query client side im not sure how this can be achieved, is there any examples on using a live query from cloud code and subscribing to it from client side ? so far this is what im doing clientside but it needs to be server side
chatSync = async () => {
const currentUID = this._api.current().id
const currentSession = this._api.current().getSessionToken()
const query = new Parse.Query(‘SpecialObject’).contains(‘users’, currentUID );
const subscription = await query.subscribe(currentSession);
let data: Array = ;
subscription.on(‘open’, async () => {
let results = await query.find()
let threadsParse = JSON.parse(JSON.stringify(results))
for (let index = 0; index < threadsParse.length; index++) {
const thread = threadsParse[index];
data.push({…thread})
console.log(data ${JSON.stringify(data)})
}
});
}
You can pass the master key by using the advanced api, it is not secure to use the master on the client for most of the cases though. JavaScript Developers Guide | Parse
I’ve followed the docs on using the advanced API, I pass the mastery to the LiveQueryClient but it doesn’t use it. I can test it, if I add a private ACL to an object it won’t trigger the LiveQuery on update, set the ACL to public it will. This is all on the backend(node). Is there somewhere else I should pass the master key?
let client = new LiveQueryClient({
applicationId: process.env.APPID,
serverURL: process.env.SERVERURL,
javascriptKey: process.env.JSKEY,
masterKey: process.env.MASTERKEY,
})
client.open({ useMasterKey: true })
const qry = new rParse.Query(‘private’, { useMasterKey: true })
let sub = client.subscribe(qry)
sub.on(‘update’, (info) => {
console.log(‘update’, info)
})
As you can see I’ve stuck “useMasterKey” everywhere I can think of, no joy.
Anyone found any solution for this?
I’m trying to create livequery client using the advance api in my node environment, client seems to work as it logs the open event, but none of ‘create/update…’ works for non-public objects. Looks like masterKey is not being applied to the socket.