SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

Multiple 'keys' query parameter doesn't help #395

Closed austinrappa78 closed 3 years ago

austinrappa78 commented 3 years ago

Most libraries for java, .net, angular, javascript, and more, use hashmaps for their http query parameters. So building a RESTHeart query with multiple keys values is not easy without 3rd party libraries or custom code to support RESTHeart's projection implementation.

Expected Behavior

Let's say we have the following Angular code:

    const url = '/inventory';

    const params = new HttpParams()
      .set('keys', `{'a':1}`)
      .set('keys', `{'b':1}`)
      .set('keys', `{'c':1}`);

    return this.http.get(url,
      {
        params
      });

RESTHeart expects this:

GET /inventory?keys={'a':1}&keys={'b':1}&keys={'c':1}

But Angular, as well as most other languages I've used here, will build the request as follows because the 'keys' value for the HttpParams keeps getting updated.

GET /inventory?keys={'c':1}

Possible Implementation

Perhaps keys can also support an array:

GET /inventory?keys=[{'a':1},{'b':1},{'c':1}]
ujibang commented 3 years ago

Having multiple query parameter values is optional, you can do

GET /inventory?keys={'a':1,'b':1,'c':1}
austinrappa78 commented 3 years ago

That's it thanks.