What would be a good API format for “NOT IN” clause?

左心房为你撑大大i 提交于 2020-01-07 07:59:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!