How to search and filter in an adonis js relationship?

Hello friends! I had some time without asking around here because it has been easy for me to find a solution to the problems that I have encountered, but right now I am facing a wall.

I have this query:

                const themes = await Theme.query()
                .with('users')
                .orderBy('created_at', 'DESC')
                .paginate(params.page, 3)

I am trying to filter the “id” of the user in session by looking in the “users” table so that the “theme” does not return if there is the “id” of our user, there is no way to do it … I tried to replace the previous method for this :

const theme = await Theme.query()
        .select('users.id AS tenertema',
        'theme.id AS id', 
        'theme.nombretema AS nombretema',
        'theme.creador AS creador',
        'theme.estilonavbar AS navbar',
        'theme.estiloiconos AS iconos',
        'theme.estilopagina AS pagina',
        'theme.background AS Fondo',
        'theme.userbox AS ubox',
        'theme.postbox AS pbox',
        'theme.colortexto AS texto',
        'theme.moneda AS pay',
        'theme.precio AS price',
        'theme.created_at AS created'
        )
        .from('users')
        .leftJoin('interthemes as IT', 'IT.user_id', '=', 'users.id')
        .leftJoin('themes as theme', 'IT.theme_id', '=', 'theme.id')
        .whereNot('theme_id', null)
        .whereNot('user_id', null)
        .where('user_id',user.id)
        .orderBy('created', 'DESC')
        .paginate(params.page, 3)

What is the main problem of this? is that being a many-to-many relationship, the object that belongs to my user not return but the same “theme” return when it belongs to other users, that is, the object is multiplied with each user to whom it belongs, it has been a Headache recently i ask after two or three days of searching without finding a solution Thank you very much in advance!

So you don’t want to see themes that belong to the logged in user?

Also, can you please share models and relationships as well as migration files.

Thanks Tsume

in this case this is a store and I only want to see the “themes” only once, that is, when they belong to me or not, what I don’t want to see is when they belong to other users

this is my model

// in theme model
users () {
    return this.belongsToMany('App/Models/User', 'theme_id', 'user_id')
    .pivotTable('interthemes')
    }

//user model

    themes () {
      return this.belongsToMany('App/Models/Theme', 'user_id', 'theme_id')
      .pivotTable('interthemes')
    }