Reactjs和Mongodb连接 [英] Reactjs and Mongodb connection

查看:252
本文介绍了Reactjs和Mongodb连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Reactjs和Mongodb的基本问题.我想构建一个具有搜索"功能的反应应用程序,该功能可以显示数据库的结果.但是,我在理解如何实现react应用程序和数据库之间的连接时遇到了一个问题.

I have a fundamental question about Reactjs and Mongodb. I want to build a react app which has a "search" feature that shows results from the database. However, I have an issue on understanding how to implement the connection between the react app and the database.

很抱歉提出一般问题.任何帮助或提示如何进行将不胜感激.预先感谢.

Sorry for the general question. Every help or hint on how to proceed will be appreciated. Thanks in advance.

推荐答案

反应完全与后端无关.这意味着您必须自己实现连接.

React is completely back-end agnostic. Which means you would have to implement the connection yourself.

通常的方法是,设置MongoDB和Node.js服务器(或任何您喜欢的后端),然后将Node.js服务器连接到MongoDB(通过MongoDBs JavaScript SDK)和React客户端,该客户端在浏览器到您的Node.js服务器(通过HTTP,快速框架可以在此处提供帮助).

The regular way is, you setup MongoDB and a Node.js server (or whatever back-end you like) then you connect the Node.js server to MongoDB (via MongoDBs JavaScript SDK) and your React client, which runs in the browser to your Node.js server (via HTTP, express framework could help here).

浏览器-> Node.js-> MongoDB.

Browser -> Node.js -> MongoDB.

但是MongoDB还具有一个REST接口,您可以直接通过浏览器使用它,就像以下答案中提到的那样:

But MongoDB also has a REST interface you could use directly via the browser, like it's mentioned in the following answer:

https://stackoverflow.com/a/16277603/1016383

对于概念或实验的少量证明可能会没事的.

Would probably be okay for small proof of concepts or experiements,.

这篇关于Reactjs和Mongodb连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆