So I’m working on implementing chat functionality for an app that has the following data object:
class Conversation {
String objectId;
List<BackendlessUser> participants;
List<ChatMessage> messages;
// getters & setters down here
}
Now, I need to Find conversations that have exactly specific participants so I can load the messages from them, but using a where clause like 'participants.objectid = ‘xxxxxxx’ AND participants.objectid = ‘xxxxxxx’ doesn’t seem to work for me. Any idea what I’m doing wrong? Suggestions are appreciated. Thanks.
Hello, Omar!
Try to use the following syntax: participants.objectId IN (‘abc’, ‘def’, …)
Hope it helps.
Alex
Thanks for the reply Alexandr!
The syntax you suggested seems to return Conversations that include one participant OR others. I need to retrieve Conversations that include both.
For example, let’s say that Bob and John start messaging each other, so I create a Conversation object like so:
Conversation conversation = new Conversation();
conversation.getParticipants().add(/* BackendlessUser bob goes here */);
conversation.getParticipants().add(/* BackendlessUser John goes here */);
Backendless.Persistence.of(Conversation.class).save(conversation, .... ); // etc
Later, I want to find the Conversation in which Bob AND John where participants.
Ok, I’ve got your case. Unfortunately, there is not direct way to implement it now. As a workaround I can suggest you to implement your case in hosted service.
Anyway, I’ve created an internal ticket for this task. It’s ID is BKNDLSS-12975.
We shall discuss it and inform you about estimations.