Back

How to use `OR` operator in Query?

  • 0
  • Databases
manazo
10 Nov, 2023, 10:04

i'm working on a chat functionality. so in all chat applications, we see a chats list on the left that shows with whom you're chatting or have chatted with. either you're the receiver or the sender, it shows the chat item. so to get a list like this, we need to pass a query where the sender_id or the recipient_id is equal to the current user id. we can do an OR operation for a value of any attribute by passing an array in the 2nd argument of the equal method. but what i need here is something like an OR operation for the name of the attributes and i can't find a way to do that. am i missing something?

TL;DR
User wants to know how to use the `OR` operator in a query for a chat functionality. Currently, this is not supported. User suggests using SQL as a workaround.
manazo
10 Nov, 2023, 12:43

my goal above could be achieved by the below SQL

TypeScript
SELECT * FROM chats
    WHERE (sender = {currentUser.$id} OR recipient = {currentUser.$id}) ORDER BY timestamp

in case it helps

Drake
10 Nov, 2023, 19:23

This is not supported at the moment. See https://github.com/appwrite/appwrite/issues/2740

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more