SoftInstigate / restheart

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

http request #53

Closed Qahraman closed 8 years ago

Qahraman commented 8 years ago

My request returns as follow : {"_embedded":{},"_links":{"curies":[{"name":"rh","href":"http://www.restheart.org/docs/v0.10/#api-doc-{rel}"}],"self":{"href":"/firstProject/N_SENSOR_ARCHIVE/55e6b2fcb03e1b93c4602fd8"},"rh:coll":{"href":"/firstProject"}},"_created_on":"2015-09-02T08:27:40Z","_type":"DOCUMENT","SENSOR_ID":1439,"RECIEVED_DATE":{"$date":1423906060362},"_id":{"$oid":"55e6b2fcb03e1b93c4602fd8"}}

I want to return from their only "SENSOR_ID" and "RECIEVED_DATE" fields.How can I disable others?

ujibang commented 8 years ago

you can control the properties to return via keys query parameter

http://restheart.org/curies/1.0/keys.html

however the HAL properties (starting with _) cannot be filtered out. there is an improvement in the roadmap to allow to filter out HAL properties selectively

have a look here https://softinstigate.atlassian.net/browse/RH-109

Qahraman commented 8 years ago

OK.Thank you very much

ujibang commented 8 years ago

For your information, the improvement is on the way, you can find it in the latest commit.

basically, if you add the hal=c (c stands for Compact) query parameter, the HAL representation will not include some information.

In your case, it will be:

{
"_links": {
  "curies":[],
  "self": {"href":"/firstProject/N_SENSOR_ARCHIVE/55e6b2fcb03e1b93c4602fd8"}
 },
 _created_on":"2015-09-02T08:27:40Z",
 _last_updated_on":"2015-09-02T08:27:40Z",
 "_type":"DOCUMENT",
 "SENSOR_ID":1439,
 "RECIEVED_DATE":{"$date":1423906060362},"
 _id":{"$oid":"55e6b2fcb03e1b93c4602fd8"}
}
Qahraman commented 8 years ago

Thanks @ujibang