Send data through Live Query to the server

Hello Parsers!
I’m trying to create a react chat application using parse server and JS SDK. There’s something I can’t figure out. I want to implement the feature of messages getting seen. Does JS SDK’s live query support updating database like the objects? Or I need to listen for incoming websocket messages on server through cloud code?

Yes, you can listen on the server side and do it anything!

Would you let me know how? Perhaps starting by a cloud function. So what’s inside it? Just a server instance that listens to ws port? Wouldn’t it interfere with live query?

Or you can use the afterFind hook, when the user reaches the messages you can directly change the messages seen field.

You can improve the code for your project requirement.

Parse.Cloud.afterFind('messageCollection', async req => {
  const message = req.objects;
    if (message.get('receiver') == req.user.id) {
     await message.set('seen', true).save();
    }
  return message;
});