knex json array of object where condition

Viewed 26

I have a json array (composition) in my db and i need to make conditions

[ { "name": "Rock", "prices": [ { "price": 400, "duration": 40 } ], "description": "Hello", "nb_musicians": 40 } ]

And i try something like this but dont work

      .where(qb => {
    if (nbMusicians) {
      qb.whereRaw(
        `composition->
      '$.nb_musicians' = ?`,
        [40],
      );
    }
  })

Thanks for help

0 Answers
Related