How to implement complex queries with a REST api?

前端 未结 2 1722
迷失自我
迷失自我 2021-02-19 07:13

I\'m building an EmberJS app using ember-data.

Some of the functionality in my app requires quite complex queries.

As an example, let\'s say I have three entitie

2条回答
  •  长情又很酷
    2021-02-19 07:39

    You can transform your

    GET /students/custom/born_before/{date}/taught_by/{teacher_id}
    

    into

    GET /students/?born_before={date}&taught_by={teacher_id}
    

    which is just a "query by example" option: you can populate a model instance with the provided fields and make a query using them. The less fields, the broader is the search and more results to show.

    This is the way JIRA's API works, for example.

提交回复
热议问题