Back

Queries

  • 0
  • Databases
  • Web
  • Cloud
nachol_
21 Dec, 2024, 12:45

Is there some difference if I do this:

const promise = databases.listDocuments( database, collection, [ Query.equal('userId', userId), Query.equal('groupId', payload.groupId) ] );

instead of using "and" query:

const promise = databases.listDocuments( database, collection, [ Query.and([ Query.equal('userId', userId), Query.equal('groupId', payload.groupId) ]) ] );

TL;DR
Developers are asking if there's a difference between using multiple Query.equal statements versus using a single Query.and with both conditions inside when performing a database query. Solution: Both methods achieve the same result in this scenario, so you can use either based on your preference or readability of code.
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