I am having trouble getting data that is input in a URL most especially when the data being accessed is an object.
Example URL:
- localhost:9000?building=Salesforce&city=San Francisco&date=January 10
- localhost:9000?grade=A
- localhost:9000?subject=Science
Sample data:
{
Name: "Andrew"
address: Object
building: "Salesforce"
city: "San Francisco"
grades: Object
0: Object
date: 2020-1-30T00:00:00.000+00:00
grade: "A"
subject: "Science"
1: Object
date: 2020-1-28T00:00:00.000+00:00
grade: "C"
subject: "Math"
2: Object
date: 2020-2-28T00:00:00.000+00:00
grade: "B"
subject: "Chemistry"
}, {
Name: "Steven"
address: Object
building: "Empire State Building"
city: "New York"
grades: Object
0: Object
date: 2020-1-30T00:00:00.000+00:00
grade: "B"
subject: "Computer Science"
1: Object
date: 2020-1-28T00:00:00.000+00:00
grade: "A"
subject: "Math"
2: Object
date: 2020-2-28T00:00:00.000+00:00
grade: "C"
subject: "History"
}
What would be a good query to return the correct data of the APIs above using mongoose?
Also, how would I get the unique values with distinct() for
- building
- city
- date
- grade
- subject