FOSElasticaBundle icon indicating copy to clipboard operation
FOSElasticaBundle copied to clipboard

I want to get all Query\Match and show relations if relation condition is true

Open tecnoher opened this issue 5 years ago • 0 comments

Hi everyone, I'm stuck with this for a few days, I want to get all related data to a random query, and for each registry I need to show its's relation if a condition exist

query: "begginer" internal condition: "user_id=3"

the result must bring all courses with word: "begginer" and in those with user_courses relation, those with user_id=3 can someone help me please?

e.g.:

Courses: [
  {id:1, title: begginer_class1},
  {id:2, title: begginer_class2},
  {id:3, title: advanced_xx}
]

UserCourses:[
  {id:1, user_id:3, course_id:1},
  {id:2, user_id:4, course_id:1}
  {id:3, user_id:5, course_id:2}
]

response:

data: [
  {
    id: 1,
    title: begginer_class1,
    user_courses: [
      id: 1,
      user_id: 3,
      course_id:1
    ]
  },
  {
    id: 2,
    title: begginer_class2,
    user_courses: []
  }
]

tecnoher avatar Oct 16 '20 21:10 tecnoher