An example of what I am trying to do:
Retrieve a list of students who are enrolled in both Maths and Physics. I appreciate any help that is offered
An example of what I am trying to do:
Retrieve a list of students who are enrolled in both Maths and Physics. I appreciate any help that is offered
Can you share the code what you are trying.
I am trying to for example retrieve students who are enrolled in Maths and Physics:
student: {
$and: [
{
course:{
$eq: 'Maths'
},
},
{
id:{
$eq: 'Physics'
},
},
]
}
With $or all students who are enrolled in either maths or physics are retrieved. With $and nothing is retrieved
I believe it should work. However can you try this
$and: [
{
student:{
course:{
$eq: 'Maths'
},
}
},
{
student:{
id:{
$eq: 'Physics'
},
}
},
]
I just tried that again (i had previously tried) amd it did not work. I substituted with a $or and that worked again (i.e. retrieved the records based on or). Do you have any other suggestions? I really appreciate your effort so far!
may I know the content-type schema of your page. I want to understand how you are storing values for the Maths
and Physics
for one student.
Student is a collection and has a relationship with courses (many to many), course is a relation type (has relationship to Student) and course has an id field which is of type text
I got your problem.Its related to many
relation and not with $and operator i think. Unfortunately I am also not sure how to fetch records in many relation in such case
What if the relationship is a one to many?