0

Knex has the ability to find records by matching string in the target column. just like https://github.com/knex/knex/issues/2009. But i have nested schema like

User: {
   id: 1,
   email: 'test_user@test.com'
   active: true,
   profiles: [
     {name: 'test 1' },
     {name: 'test 2'}
   ]
 }

Schema

User = {
  id: number,
  email: string,
  active: boolean
}

Profile = {
  id: number,
  name: string,
  userId: number => ref to user table
}

and there is OneToMany Relation between User and Profile.

I want to find the records where search text is like name in profiles array. How to do that?

Ahmad Raza
  • 21
  • 7

0 Answers0