我们应该如何设置我们的数据库(MongoDB)和后端(Express)以便每个人都可以远程访问数据库?

发布于 2025-01-17 21:51:39 字数 380 浏览 3 评论 0原文

问题

我是一名学生,被分配到一个项目来创建一个基本的社交媒体应用程序。我们计划使用 Flutter 来构建应用程序,并分别使用 MongoDB 和 Express 作为数据库和 API。目标是能够通过 Fastlane 和 GitLab 对我们的项目使用持续集成。

最初,我想将 API 和 Flutter 放在单独的 Docker 容器中,并将数据库托管在我的桌面上,但我意识到这可能不是最好的解决方案。

问题

我们应该如何设置数据库和服务器,以便我们都可以访问数据库中的相同数据?基本上,我们应该如何最好地设置我们的项目环境以团队合作,在以下方面:

  • 托管数据库?
  • 设置 Express 和 Flutter 进行持续集成?

The Problem

I am student assigned to a project to create a rudimentary social media app. We are planning to use Flutter to build the app and we are going to use MongoDB and Express for the database and API respectively. The goal is to be able to use continuous integration for our project through Fastlane and GitLab.

Initially, I thought to put the API and Flutter in separate Docker containers and to host the database on my desktop, but I realize that might not be the best solution.

The Question(s)

How should we setup the database and the server that we all have access to the same data in a database? Basically, how should we best set up our project environment to work as team, in terms of:

  • hosting the database?
  • setting up Express and Flutter for continuous integration?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜清冷一曲。 2025-01-24 21:51:39

如果您使用的是mongodb,则只需在

基本上,您要做的就是在数据库连接链接中使用已配置的密码链接到群集的链接。这一切都在云中,因此您可以在白名单之后从任何地方访问IP之后,将远程访问它。 (另外,您可以将所有IP白色列出来,这是做事的更轻松的方法,这只是安全性要少得多。)但是对于学校项目来说,这是一个可以的选择。

然后,您可以使用 heroku 托管您的应用程序,该应用程序允许像您使用Express一样的自定义服务器设置。

您将需要使用 dotenv for heroku for heroku for heroku以及确定您的数据库链接和密码,因此请阅读也要上。

If you are using MongoDB just set up a cluster on Atlas it's free as long as it's a relatively small application (up to 500MB). After you sign up, you will create a cluster, and then Atlas will give you instructions on how to connect to that cluster using node.js.

Basically all you do is throw in the link to your cluster with your configured password in your database connection link. This is all in the cloud so you can access it from anywhere after you whitelist the IP's that will be accessing it remotely. (alternatively you can whitelist all IP's which is the easier way of doing things it's just A LOT less secure.) but it's an okay option for a school project.

You can then use Heroku to host your app which allows for a custom server setup like you will have with Express.

You will need to use dotenv for heroku as well as securing your database link and password, so read up on that as well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文