node.js - 如何在 Nodejs 中动态创建 MongoSchema
问题描述
我正在按照这种方式。
var mySchema = new Schema({
Id : {type: String},
Name : {type: String}
}, {strict: false});
module.exports = mongoose.model('account', mySchema);
它工作正常,但是每次我重新启动服务器时,我的收藏都会自动消失..我正在使用这种方式来获取收藏
const collections = Object.keys(mongoose.connection.collections);
return res.status(200).json({status:true,msg:collections})
重新启动服务器集合后显示为空,我在做什么?
解决方案
推荐阅读
- r - 为什么因子不包含在一阶差分模型中?
- c++ - 联合铸造初始化和引用内部结构
- c# - 将数据从unity发送到sql数据库
- mongodb - 如何解组非平凡的 mongo 返回 bson 结构
- reactjs - 我不断收到“handleColor”不是函数错误
- javascript - lb4 调用不同存储库中的另一个存储库
- android - Android 的 OnKeyDown 在 Delphi 10.4.1 中不起作用
- c - gcc -O2 创建一个无限循环,可能是因为未定义的行为
- python - Python 机器学习 - 基于规则的匹配
- reactjs - React 从基于 id 的路由重定向到 404 路由