java - REST API filtering with related resources best practices -
what best practice include related resources in search query?
my resources are:
/projects /participants /questions /questionanswers
the query like: participants are:
- between age of 20 , 40 and, - male and, - selected answer x of question y
would
/participants?search=gender:male,age>=20,age<=40,question:x,answer:y
is there better or standard way type of queries?
you can use object serialization & filters. like:
/participants?filter={gender={male}, age={between={20, 40}}, question={x}, answer={y}}
for given example with:
- gender = male, female
- age = (1...99) or between={start, end} or till={end} or from={start} etc..
in case, have possibility filter more specific and/or combined. combination example:
/participants?filter={gender={male, female}, age={21,22, 23, from={40}}, question={x}, answer={y}}
result: gender male , female age 21, 22, 23 , 40 till 99 (or want)
Comments
Post a Comment