SoftInstigate / restheart

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

Filter a collection by Suffix #284

Closed fdrsuisse closed 6 years ago

fdrsuisse commented 6 years ago

Hi, we have a DB named "sth_carouge_copy". When we query it (http://10.1.17.113:8080/browser/#/sth_carouge_copy) it returns a list of collections:

{ "_id": "sth_carouge_copy", "_size": 1480, "_total_pages": 15, "_returned": 100, "_type": "DB", "_embedded": { "rh:coll": [ { "_id": "sthxffffx002fairno2xffffForonxffffNO2xffffAirQualityObserved", "_type": "COLLECTION", "_links": { "self": { "href": "/sth_carouge_copy/sthxffffx002fairno2xffffForonxffffNO2xffffAirQualityObserved" } } }, { "_id": "sthxffffx002fairno2xffffForonxffffNO2xffffAirQualityObserved.aggr", "_type": "COLLECTION", "_links": { "self": { "href": "/sth_carouge_copy/sthxffffx002fairno2xffffForonxffffNO2xffffAirQualityObserved.aggr" } } },

We tried the following queries:

  1. "http://10.1.17.113:8080/browser/#/sth_carouge_copy?filter={'_id':{'$regex':'.*AirQualityObserved$'}} This one should filter by suffix "AirQualityObserved"

  2. "http://10.1.17.113:8080/browser/#/sth_carouge_copy?where={'_id':'sthxffffx002fairno2xffffForonxffffNO2xffffAirQualityObserved'}"

We read your documentation and you proposed to make filters using \/\?filter=.... to filter documents in collections. Is there a way to filter collection directly in db? Best Regards, Francesco

ujibang commented 6 years ago

No, filter qparam does not apply to GET /db requests

mkjsix commented 6 years ago

@fdrsuisse what do you want to actually achieve?

fdrsuisse commented 6 years ago

We would like to filter collections using a suffix such as "AirQualityObserved". This suffix is contained in many "idCollections" and it gives the type of a collection

"http://10.1.17.113:8080/browser/#/sth_carouge_copy?filter={'_id':{'$regex':'.*AirQualityObserved$'}} This one should filter by suffix "AirQualityObserved"

mkjsix commented 6 years ago

@fdrsuisse does that work with a direct MongoDB query, I mean without RESTHeart involved? I never tried.