Skip to content
Back

[SOLVED] Array value during query

  • 0
  • Databases
  • Web
  • Cloud
omzi
5 Jun, 2023, 19:57

Okay, so I want to find all documents whose author field is contained in the enum passed in. Right now, I can only send a string value. I also found out that someone has reported a bug about it here: https://github.com/appwrite/appwrite/issues/3914.

TL;DR
The user is experiencing an issue with passing an array value during a search query. The solution is to check if the array is empty and only pass the query if it is not empty. The issue will be fixed in the next version of Appwrite. The user is advised to print the array value before the query to troubleshoot further. The user also mentions confusion between the terms 'enum' and 'array', and the correct usage is clarified.
omzi
5 Jun, 2023, 19:59

Basically, Query.equal('author', 'yourRandomId') works. Query.equal('author', ['yourRandomId1', 'yourRandomId2', 'yourRandomId3']) doesn't.

Drake
5 Jun, 2023, 19:59

im still not sure where enum fits in..

Drake
5 Jun, 2023, 20:00

and what exactly is the error you're getting?

omzi
5 Jun, 2023, 20:03

Enum is the array value, in this case ['yourRandomId1', 'yourRandomId2', 'yourRandomId3'].

Here's the error I'm getting:

TypeScript
    message: 'Server Error',
    code: 500,
    type: 'general_unknown',
    version: '0.10.28'
}```
Drake
5 Jun, 2023, 20:04

is the attirbute an enum or a string?

omzi
5 Jun, 2023, 20:04

The attribute is a string but I want to match it against an array of strings (enum).

omzi
5 Jun, 2023, 20:05

Is that possible?

Drake
5 Jun, 2023, 20:05

that's not an enum...that's just an array of strings

Drake
5 Jun, 2023, 20:05

what's your project ID?

omzi
5 Jun, 2023, 20:06

Technically, yes 😅 . I tend to use them interchangeably.

My project ID is 64796cdb64c159ad2827

Drake
5 Jun, 2023, 20:07

Technically, yes 😅 . I tend to use them interchangeably.

Don't do that...it's very confusing to use a term incorrectly

omzi
5 Jun, 2023, 20:07

Noted.

Drake
5 Jun, 2023, 20:07

what exactly is your code?

omzi
5 Jun, 2023, 20:08

Gimme a sec please

omzi
5 Jun, 2023, 20:10
TypeScript
                Query.equal('author', followedUsers),
                Query.orderDesc('$createdAt')
            ]);```
Drake
5 Jun, 2023, 20:11

can you print followedUsers before this line?

omzi
5 Jun, 2023, 20:11

Right now, followedUsers is an empty array so the value is [].

Drake
5 Jun, 2023, 20:12

so this will be fixed in the next version of Appwrite: https://github.com/appwrite/appwrite/issues/5522

For now, you should check if followedUsers is empty and only pass the query if followedUsers is not empty

Drake
5 Jun, 2023, 20:13

Array value during search query

Drake
5 Jun, 2023, 20:13

Array value during query

omzi
5 Jun, 2023, 20:14

Oh, oh, oh. That's good to know. I had a feeling that might be the case.

Thanks a lot for your help & sorry again for tagging you (and for the earlier confusion) 🙏🏽 .

Drake
5 Jun, 2023, 20:15

👍🏼 no worries!

Drake
5 Jun, 2023, 20:15

[SOLVED] Array value during query

dammy
10 Jun, 2023, 06:02

what a leader you are @Steven 😇

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