我们如何使用MEAN-stack从两个不同的数据库中访问同一页面上的数据?例如,我想在同一页上给出用户信息和用户观看历史(两者都是不同的数据库)?
发布于 2018-11-17 01:42:04
你可以为你单独的mongoose连接创建多个文件。例如在db_one.js
中
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/db_one');
module.exports = mongoose;
然后在db_two.js
中
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/db_two');
module.exports = mongoose;
然后根据需要将它们导入到其他文件中
https://stackoverflow.com/questions/53342566
复制相似问题