简体   繁体   English

静止投影

[英]Projection in Rest

We are using projection in Rest Web-service. 我们在Rest Web服务中使用投影。 The Approach we are following is: 我们遵循的方法是:

?projection= (attr1,attr2)&include=0.

where projection string contain name of all the variable which we want to include or exclude from output object. 其中投影字符串包含我们要包含在输出对象中或从输出对象中排除的所有变量的名称。 If the include is 0 it means we want to exclude variable and if include is 1 means we want to include variable which are given in projection string . 如果include0则表示我们要排除变量;如果include为1表示我们要包括projection字符串中给出的变量。 Is this is correct and RESTful? 这是正确的并且是RESTful的吗?

There's nothing bad in this approach when it comes to being RESTful or RESTless. 无论是RESTful还是RESTless,这种方法都不错。 On the contrary, field projection is very good practice which is widely utilized. 相反,场投影是非常好的实践,被广泛使用。

I don't know your scenario well, however the suggested solution seems to be too complicated. 我不太了解您的情况,但是建议的解决方案似乎太复杂了。 I'd rather remove include field and if projection is empty return the whole resource, otherwise return only the fields listed under projection query param. 我宁愿删除include字段,如果projection为空,则返回整个资源,否则,仅返回在projection query param下列出的字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM