Back

Query question

  • 0
  • Databases
  • Web
Vilian
23 Nov, 2024, 11:53

Hey there o/

Just a quick sidenote - Recently joined the student program and i'm loving what appwrite is providing me with. It's an amazing backend, but i'm also having a few pain points i would like to talk about.

I'm curious as to how one is supposed to do a not in query. For example, imagine i have two collections with a one sided relation between them. Collection A has some product data, Collection B has a description and score for a product in the A collection and that B record belongs to a user. (basically, a user can only grade a product from the A collection once) My goal was to visualise this on the frontend and offer a nice ui for it, however due to my lack of knowledge (since i'm still a student) and no previous experience with such document databases (even though we are on top of mariadb), i found it incredibly difficult to do so.

I had to basically walk over the entire B table, retrieving records that belonged to the user, then proceded to retrive records from table A and discarding them on the frontend if any of them were already being pointed at by a record in B (since that would mean that the A records was already graded by a B record and there is nothing to do)

TL;DR
Developers are struggling with querying in a document database, looking for pointers on improving their approach. They want to know how to perform a 'not in' query for two collections with a one-sided relation. The solution would involve looping through Collection B to find records related to a user, then retrieve records from Collection A and filter out those already associated with B records.
Vilian
23 Nov, 2024, 11:53

So here i am posting about this

Vilian
23 Nov, 2024, 11:55

Since i tried to search only for this. I was pretty sure that if there existed a query like Query.notequal('$id', [....all the ids i do not want to see.....]) my life wouldve been a lot easier

Vilian
23 Nov, 2024, 11:55

But perhaps i'm way too used to relational databases and my approach is wrong

Vilian
23 Nov, 2024, 11:55

Could someone people give me a few pointers on what can be improved here because i feel so lost

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