For any REST API, operations like querying, sorting, filtering are a must have. In the beginning I assumed that it was good enough for the client to fetch all the data, and perform these operations on their side. This was good enough for a PoC or a PET project, but far from ideal for a production application, not only because of the size of the data transferred, but also had security implications, as some sensitive data could be exposed.
I wondered for a while what would be the best and quickest solution for this. Implementing all of this came through my head, but then I thought, this is a common problem and I'm sure there are existing solutions for this.
I was right! I came across JSONata, a really powerful library that did everything what I was looking for and more!
All I had to do was add support for JSONata expressions for GET requests and it worked perfectly.
How does it work? GET requests accept a new parameter called jsonata that accepts encoded JSONata expressions.
I hope you find these expressions useful. If you have any questions don't hesitate to reach out, after all, feedback is what makes any product great!
Take care and until the next one!