Back

[SOLVED] NotEqual comparison error

  • 0
  • Databases
Said H
17 Feb, 2023, 01:36

if so, then it is not helpful for notEqual

TL;DR
The user is experiencing a NotEqual comparison error while trying to delete documents. They are looking for a way to check if a document is in a hash/map/set and delete it if it isn't. One suggestion is to maintain a list of all research papers in a secondary metadata collection or file in Storage to improve efficiency. Another option is to separate the NotEqual queries into separate queries instead of using an array. There may be a limit on the number of query strings allowed per query. The issue was resolved by using separate NotEqual queries instead of an array. The user also suggests the possibility of Appwrite adding support for arrays in the future
Said H
17 Feb, 2023, 01:36

and it makes sense why it returns back all my existing data

Drake
17 Feb, 2023, 01:36

When you pass multiple values, it becomes OR.

But again, this is not supported on array attributes

Said H
17 Feb, 2023, 01:37

i see... do you think in future, there may be a possibility to have a query method that will check notEqual against an array, but using AND, instead of OR?

similar to SQL's "NOT IN"

Drake
17 Feb, 2023, 01:40

Yes, we do want to add support for arrays...something might be coming in our next release...I can't remember

Said H
17 Feb, 2023, 01:40

yay! thanks so much Steven

VincentGe
17 Feb, 2023, 16:37

No, this should work. Array operations are joined with "OR" operations

VincentGe
17 Feb, 2023, 16:37

Nvm I see steven has responded πŸ˜›

VincentGe
19 Feb, 2023, 16:35

[SOLVED] NotEqual comparison error

Said H
20 Feb, 2023, 08:46

Thanks @VincentGe , yeah it works as an OR operator, but it defeats my purpose because it just returns back all records in DB πŸ™‚

VincentGe
20 Feb, 2023, 15:35

You can pass them as separate queries

VincentGe
20 Feb, 2023, 15:35

Each query string is logically separated via AND. For OR logic, pass multiple values, separated by commas:

VincentGe
20 Feb, 2023, 15:36

Do 3 separate not equal queries instead of one with an array πŸ™‚

VincentGe
20 Feb, 2023, 15:37

so [sdk.query.notEqual(field, "a"), sdk.query.notEqual(field, "b"), ...]

Said H
21 Feb, 2023, 01:21

aha! by any chance, would you know if appwrite has a limit of how many query string is permitted per query? If i have to separate the NotEqual queries, I will need to dynamically append it >5k times as i have those large number of data to compare. Ideally array will work best for me.

Said H
21 Feb, 2023, 01:22

I will give it a try.

Said H
21 Feb, 2023, 01:23

Thanks for this suggestion, @VincentGe

Drake
21 Feb, 2023, 01:29

I think there's a limit of 100 queries in a single API call

Said H
21 Feb, 2023, 01:32

ah. ok. thanks @Steven

VincentGe
21 Feb, 2023, 05:09

πŸ₯Ή 5000 not equal operations? That's really interesting, I wonder if there are ways to optimize that from the design side. It is quite extreme, even if you're writing SQL.

I guess you'd normally do like a left outer join πŸ€”

If you'd like to share your use case, it would help us improve Appwrite <:appwritepeepo:902865250427215882> We love hearing use cases we have not imagined before!

Said H
21 Feb, 2023, 06:52

Absolutely. So, everyday, I am doing a validation (via a batch job) to verify whether the existing "Research Papers" records that i have inserted in DB is missing. I would scan all the papers from a webpage, then verify whether any of the old paper was removed (it happens). If I have a record in my DB, but not in the webpage, it means the paper was already taken down. And I want to be aware of that.

NotEqual Array is the best for me because i can push all the papers into the Array and it will only return me the record that does not exist. But, the NotEqual Array is doing OR, which means it does not serve my purpose.

Right now, i will wait for AppWrite to support Array (AND operator).

Said H
21 Feb, 2023, 06:54

in SQL, I usually just do "NOT IN (list of records)" and that solves my problem

VincentGe
21 Feb, 2023, 15:48

Does it need to be executed synchronously?

Drake
21 Feb, 2023, 17:49

Maybe you can have a function that:

  1. Fetches all research papers
  2. Creates a hash/map/set so i can do a O(1) lookup
  3. Iterates over all Research Papers in the appwrite database (list documents with cursor based pagination)
  4. Checks if document is in hash/map/set from step 2
  5. If it isn't, delete the document.

One way to improve this is to maintain a list of all the research papers in a secondary metadata collection or maybe a file in Storage. Then, instead of using list documents to get the research papers from the Appwrite Database, you can use the list

Said H
21 Feb, 2023, 22:19

ok, i will give this a try. Thanks a lot @Steven and @VincentGe

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