Back

Neither Query.search() works nor Query.equal()

  • 0
  • Databases
Infinil
29 Aug, 2023, 10:57

So currently I have been trying to get list of documents where I am trying to find a string out of array of strings (attribute in collection). Query.equal("ids", myString) did not work so I tried Query.search("ids", myString) after making a fulltext index but realised search does not work with underscore in the ids. Not sure what to do here ;-;

TL;DR
The user is having trouble with the Query.search() and Query.equal(). They are unsure if they need to sanitize strings for SQL injection when using Query.search(). They are also wondering if relationship queries will be added in Appwrite 1.4. Another user suggests using the parent ID in the child document to filter children. The user has changed the IDs in the collection to use underscores and regrets it because Query.search() does not work with underscores. They tried using Query.equal() but it also did not work. The solution is to use a different naming convention for IDs or find an alternative method to achieve the desired result.
Infinil
29 Aug, 2023, 11:31

btw Query.search() works fine if there is no underscore or other special characters

Infinil
29 Aug, 2023, 11:31

but the way i have made IDs in collection are with underscore (kinda regretting it now)

Infinil
29 Aug, 2023, 16:59

i changed the IDs.. works now and i dont think it will be possible any other way since its just how fulltext indexes work in maria db πŸ€”

Infinil
29 Aug, 2023, 17:00

but yea relationship queries will be a game changer here

Drake
29 Aug, 2023, 17:28

I typically put the parent id in the child document. Then I can filter for children with parent id = XYZ.

Drake
29 Aug, 2023, 17:29
Infinil
30 Aug, 2023, 04:44

i see πŸ‘ btw can i expect relationship queries in appwrite 1.4?

Infinil
30 Aug, 2023, 04:46

another question (offtopic) do i need to purify string before passing it in Query.search? can there be sql injections if i dont?

Drake
30 Aug, 2023, 05:42

Not yet

Drake
30 Aug, 2023, 05:42

No need to worry about SQL injection

Infinil
30 Aug, 2023, 05:52

Gotcha!

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