I'm building a web application using REST; more specifically, Node.js. So far, I've had no problems formatting the URL (using ? and & operators; limit and skip to filter fields, for example).
Now, I need to filter a list of Sensor Readings to show only the data that was inserted in a specific day.
The date is being stored as a String in MongoDB in the format "dd/mm/yyyy hh:mm:ss", or "25/04/2017 10:20:56". The reason I'm storing it as a String rather than as datetime is because it takes less space, as there's limitations of storage in the project.
Using the "like" operator in the URL (%, that is), I've successfully managed to filter some other String fields, such as /sensorReading/?deviceNum=MBA%. However, when I try to filter the date String, it fails.
I've tried in many different ways, but nothing is working, even when I don't use the like operator and put the full string (space is being replaced as %20):
/sensorReading/?dateString=13%
/sensorReading/?dateString=1%
/sensorReading/?dateString=%1%
/sensorReading?dateString=1%
/sensorReading/?dateString=13/04/2017%2012:57:16
My guess is that it has something to do with the '/' character present in the String, to separate day, month and year.
Is there a way to do this via URL, or will I have to do it in the front end of my aplication? For the front, I'm using JavaScript and AngularJS.
via Ernani
No comments:
Post a Comment