【发布时间】:2021-10-03 12:15:49
【问题描述】:
我在 heroku 上托管我的 discord 机器人,我安装了这个数据库来添加文件,因为据我所知,heroku 有一个临时文件系统,而且像 fs 这样的东西也不再工作了。这是我安装的插件:https://elements.heroku.com/addons/heroku-postgresql
这是我用于附加到 txts/json 文件的代码示例:
// Json example
if (command === 'jsonExample') {
config.example = args[0]
var stringifiedConfig = JSON.stringify(config, null, 4);
fs.writeFileSync("./config.json", stringifiedConfig)
console.log(stringifiedConfig)
}
// Txt example
if (command === 'txtExample') {
fs.appendFileSync('folder/example.txt', data + "\r\n", (err) => {
if (err) throw (err)
})
}
console.log('File edited')
问题是我不知道如何使其适应数据库,我对 heroku 很陌生,我并没有真正找到任何不和谐机器人的东西,我希望你能提供帮助。
【问题讨论】:
标签: javascript node.js heroku discord.js