问题
I have a query API against my service, that looks like this (JSON-ish format):
{
filter: {
attribute1: [val11]
,attribute2: [val21, val22]
}
}
means effectively, select data WHERE attribute1 IN ("val11") AND attribute2 in ("val21", "val22") in SQL-ish syntax.
I need to expand this API to be able to express NOT IN predicate, and I'm at a loss as to what a good way to do so would be.
The only thing I can possibly think of is to add a second "filter_not_in" key in the request API, that would work like "filter" key but produce NOT IN semantics; but it seems really klunky and hard to grasp.
The API syntax can be thought of as JSON as far as its expressiveness/capability
An ideal answer would reference some well accepted rules on API design, to show that it's "good".
来源:https://stackoverflow.com/questions/43262890/what-would-be-a-good-api-format-for-not-in-clause