5

I'm building a chat application with Parse. I have a class "Conversation" and a class "Message". A Conversation can have many messages (one-to-many) relationship.

Also, I'm using the local datastore to cache the objects (both Conversation and messages with a PFRelation). Everything works fine until I try to fetch the conversation from server for updates. Note, I'm just querying for the conversation, and hence new message objects are not fetched (which is expected according to Parse's documentation) .But surprisingly I can't even see the messages from local datastore.

Does anyone know a way to store PFRelations properly to local datastore?

1 Answers1

0

I have the same issue, same situation. Seems to be a bug in Parse SDK, see https://stackoverflow.com/a/29157525/1679768.

So now, in Message class, I have a column "conversation" which points to the related conversation pfObject. You can pin messages and find all from local datastore where key "conversation" equal to your current conversation.

let query = Message.query()
query?.whereKey("conversation", equalTo: anyConversation)
query?.findObjectsInBackground()

Keep us updated if you found another way.

Community
  • 1
  • 1
frouo
  • 5,087
  • 3
  • 26
  • 29