Listening to document changes and update it to every member

Hi everyone,

I’ve been struggling to figure out a solution, but due my lack of knowledge go backend MongoDB is really hard to do changes.

I use are reference the RChat App : RChat/RChat-iOS at main · realm/RChat · GitHub

My code: GitHub - radupatrascu/Membership-To-Conversation

Main target:

  • Dynamic adding and deleting of conversation members
  • Listen to any change in conversation embedded objects in the User.memberOf array and change the conversation settings/other field to all copies of the conversation (which appeared in members userdoc).
  • If owner of the project delete the conversation, it should trigger delete for all the members.

Issues:

  • When I add the new member, it crashes with “Could not bind value”, but still adds it to the Userdoc.memberof and other users gets the copy.

  • If adding members is done by the changeEvent trigger, ondelete action of the member, changeEvent doesn’t track that, so it could be really useful to get some help on the change event function.

  • Also how do I track any changes to additional parameters that I want to add to embedded conversation object, so it would be visible for all users.

FYI, the actual objects contain same Model as the RChat for User, Chatster, Member, Conversation as in the example done by Andrew.

Please some ease my pain :smiley:
Thank you.