Hello,
I’m using parse live query for messages, in every message, I have a user pointer “userInfo”. I want the parse live query to send this populated when it sends this new message to all observers.
For example, I’m receiving this below response in a live query stream on a new message.
I want userInfo field to include the actual info of the user instead of just a pointer.
{"op":"create","clientId":"194a758a-825b-478a-bc58-3cd722291c04","installationId":"18394ca6-c4f8-4f25-8e64-b149623f9553","requestId":5,"object":{"message":"MESSAGE","liveBreak":{"__type":"Pointer","className":"LiveBreak","objectId":"7pPLFeFVoY"},"userInfo":{"__type":"Pointer","className":"users","objectId":"63b40841ee9c12a39fe03fdc"},"createdAt":"2023-01-10T20:53:45.397Z","updatedAt":"2023-01-10T20:53:45.397Z","__type":"Object","className":"ChatMessage","objectId":"Ec3GkYo50r"}}```
cbaker6
January 12, 2023, 10:13pm
2
The LiveQuery server currently doesn’t support this. You can see an old, but still relevant discussion about this here:
opened 10:13PM - 01 May 16 UTC
type:feature
I have a table, one of the table fields points to the users table, here is my co… de:
```
var subscription = (new Parse.Query('Queue')).include('requestingUser').subscribe();
subscription.on('create', function(queueObject) {
queueObject.get('requestingUser') // user object
queueObject.get('requestingUser').get('name') // undefined
})
```
Within the parse server `index.js` I set:
```
liveQuery: {
classNames: ["_User", "User", "Queue"] // Just in case I did try "_User" and "User"
}
```
I also tried another table, other than users table, doesn't work either.
This is the response(if it helps):
```
HTTP/1.1 201 Created
X-Powered-By: Express
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
Access-Control-Allow-Headers: X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type
Location: http://localhost:1337/parse/classes/Queue/cFwSWuzUXx
Content-Type: application/json; charset=utf-8
Content-Length: 64
Date: Sun, 01 May 2016 22:04:16 GMT
Connection: keep-alive
```
Honestly, I'm not sure if it's a bug but I was trying to find out if it's even possibly to use include with live query and didn't find anything like that in the docs, but the docs suggest that subscribe is just instead of find for example so I don't think include should be a problem and it is.
You can use afterLiveQueryEvent
Parse.Cloud.afterLiveQueryEvent('TestObject', async req => {
await req.object.get("key").fetch({ sessionToken: req.user.getSessionToken() });
});
1 Like