Filtering on a relation field


I have a model which has one to many relationship with Users

I am trying to do a query for all records for my particular user as follows

let specificUsersNotifications = await strapi.db.query(‘api::notification.notification’).findMany({
where: {
users: {$contains: myUser},

I always get no results. How can I query/filter for this use case

ie users defined as follows notification has many Users

myUser should be the userID. also you should use entityservice above strapi.db.query. only use strapi.db.query when the entityservice makes what you want to do imposible

MyUser is the UserID.

My mistake you want to use $eq instead of $contains since contains is meant for string fields.

users though is an array hence my confusion

Ye it is worth to make the documentation more clear on this.

I mean $eq cant work since users contains multiple users

$eq will work. belief me.

since what strapi does when you give it a relation.

it will for loop over it and do on every record in the relation your check.