node.js - 我可以在 Heroku 上使用基于文件的数据库吗?

标签 node.js express heroku nedb

我有一个小型 Node.js/Express 应用程序部署到 Heroku。

我想使用像 NeDB 这样的轻量级数据库保存一些数据。如果我使用这种方法,是否可以定期从 Heroku 备份/复制文件?

最佳答案

基于文件的数据库不太适合 Heroku,因为其 ephemeral filesystem (加粗):

Each dyno gets its own ephemeral filesystem, with a fresh copy of the most recently deployed code. During the dyno’s lifetime its running processes can use the filesystem as a temporary scratchpad, but no files that are written are visible to processes in any other dyno and any files written will be discarded the moment the dyno is stopped or restarted. For example, this occurs any time a dyno is replaced due to application deployment and approximately once a day as part of normal dyno management.

根据您的用例,我建议使用客户端服务器数据库(这看起来很适合这里)或类似 Amazon S3 for file storage 的东西.

关于node.js - 我可以在 Heroku 上使用基于文件的数据库吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50421061/

相关文章:

javascript - 数组 .push 在 Promise 函数中不起作用

node.js - Nodejs 部署到 Heroku 时出错

node.js - 如果当前运行时支持,则使用顶级等待

node.js - 调试 Node.js 中的内存不足错误

javascript - 快速表单处理,无需重定向。有数据但没有preventDefault,但重定向。不使用 PreventDefault 进行重定向,但没有数据

javascript - 有没有办法访问 DOM 服务器端?

javascript - 带有 express Node js 服务器的 XMLhttpRequest

docker - 无法通过Travis CI将多容器应用程序部署到Heroku

javascript - 直接到 S3 文件上传 Django 和 Heroku

javascript - 在我的应用程序 angular2 aspnet core 中找不到错误 angular2-cookies/core.js