search - REST Get items not in collection -
introduction
let's have rest service returns items:
get /items /items/7 post /items etc.
we have groups of items:
get /groups /groups/16 post /groups etc.
and can items in specific group:
/items?groupid=16
this pretty straight forward.
question
now have way items in specific group, should supply way items not in specific group? why? because if client wants add items group, has know items aren't added yet.
i see 2 options:
- we supply way query data
- don't anything, let client handle it.
ad 1.
we can supply way query/search data this:
/items?groupid=!16 or /items?q=groupid<>16
i have feeling leads never ending stream of feature requests search queries.
ad 2.
the client can first items. next client can items in group 16. doing diff on these 2 collections gives items not in group 16.
this way client has little more coding, , work collections, keep them in memory etc. on other hand doesn't need learn specific query syntax.
are there best practicies on topic?
first, i'd use different url items in group:
get /groups/16/items
this return collection resource of items in group 16. add item group,
post /groups/16/items
could used.
adding item group have same result, regardless of item being in group or not. in both cases client cares result: wants item in group. if was, fine, if not, now.
so don't see usecase getting items not in group.
Comments
Post a Comment