mcnamee mcnamee - 6 months ago 51
reST (reStructuredText) Question

FeathersJS REST Multiple Query String

With the FeathersJs REST client - how can I query a single field with multiple values?

Eg. if I have a Books service and I want to retrieve all books written in the year 1990, 1991 and 1992. I'd assume I'd call:


Although this doesn't work.


Have a look at the documentation for the common database adapter querying syntax. The correct way to query for what you are looking for is:

year: {
  $in: [ 1990, 1991, 1992 ]

The corresponding query would be


Parsing this query string requires using the extend query parser qs which you can enable with

app.set('query parser', 'extended');

Since the query is a string, if you need the actual number values for the year you might also have to convert it the query in a before hook (although most database usually allow both).