Back

Query by array using NextJs

  • 0
  • Databases
  • Cloud
Denzel
15 Aug, 2024, 17:22

I have a collection “notification” with an array field “readers” that contains user IDs of any user that reader’s the notification.

I want to query by listing all notifications that does not contain the current logged in user ID if that user ID exist in the readers.

Any help or suggestions?

TL;DR
Developers want to query a collection based on an array field and exclude notifications that contain the current user's ID in the readers array. Try this MongoDB query: `{ readers: { $nin: ["current_user_id"] } }` to filter out notifications with the current user's ID.
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