简体   繁体   English

管理响应中的数据 - Node.js

[英]Managing Data in The Response - Node.js

I'm developing a node.js project and it's becoming large with many endpoints.我正在开发一个 node.js 项目,它变得越来越大,有很多端点。 Now modifying the data in the response for each endpoint has become really tedious job since I have to jump between files.现在修改每个端点的响应中的数据已经变得非常乏味,因为我必须在文件之间跳转。 For eg if I have a user model, I wouldn't return all its information in the response, only selected ones, and same for all other models.例如,如果我有一个用户模型,我不会在响应中返回它的所有信息,只返回选定的信息,对于所有其他模型也是如此。 I did a research to find any way to manage this efficiently, but couldn't find any solution.我进行了一项研究,以找到有效管理此问题的任何方法,但找不到任何解决方案。

Any suggestions?有什么建议?

Maybe a good option for you is switching your API to GraphQL.也许对您来说一个不错的选择是将您的 API 切换到 GraphQL。

With GraphQL you can avoid underfetching and overfetching.使用 GraphQL,您可以避免获取不足和过度获取。

You can see more information about GraphQL here: https://graphql.org/您可以在此处查看有关 GraphQL 的更多信息: https ://graphql.org/

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

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