扫码关注官方订阅号
上面是nodejs的入口JS文件中内容
上面是对mongoose里写的静态方法
可以看到路由在打开/pokergame路径时会调用fetch()方法,但是却没有调用出player这个collection里的内容是为什么?怎么才能在nodejs里正确获取mongodb里面的数据信息?
认证高级PHP讲师
https://segmentfault.com/a/11...
建model的页面,你得写数据库表名与schema绑定
exports.player = mongoose.model('player',PlayerSchema);
用的地方:
var Player = require('./models/model').player //这个player与上面的exports.player对上;
Player.find(....)//这样就能用了
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
https://segmentfault.com/a/11...
建model的页面,你得写数据库表名与schema绑定
exports.player = mongoose.model('player',PlayerSchema);
用的地方:
var Player = require('./models/model').player //这个player与上面的exports.player对上;
Player.find(....)//这样就能用了