简体   繁体   English

为什么我们在同一个项目中同时使用 Redux 和数据库(Mongo atlas)?

[英]Why do we use Both Redux and database (Mongo atlas) in same project?

since both acts as Centralised storage which helps us to update and retrieve data, and why people update/delete data from database as well as redux since redux fetching data from database itself right因为两者都充当集中存储,帮助我们更新和检索数据,以及为什么人们从数据库以及 redux 更新/删除数据,因为 redux 从数据库本身获取数据是正确的

Simply, database is the storage for the server and Redux is global state store for the browser.简单地说,数据库是服务器的存储,Redux 是浏览器的全局 state 存储。

Suppose you have the service that has 100,000+ users.假设您的服务拥有超过 100,000 个用户。

Redux cannot hold such size of data and if can hold the data, you shouldn't do so because user data must be kept safely in to your server. Redux 不能保存这么大的数据,如果可以保存数据,您不应该这样做,因为用户数据必须安全地保存在您的服务器中。

Instead, let the API server fetch a single user data from the database for the HTTP request and let the Redux hold the single userdata to keep the login context.相反,让 API 服务器从数据库中为 HTTP 请求获取单个用户数据,并让 Redux 保存单个用户数据以保持登录上下文。

To do so you can kept userdata safe and also keep the login context for the browser为此,您可以保持用户数据的安全并保持浏览器的登录上下文

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

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