var configDB = mongoose.model('config', configScheMa);
如上,保存数据的时候,mongodb会在集合config后面自动加s,有没有解决方法
我怀疑是mongoose这玩意搞的,它还会把大写转小写。真是自作聪明。
var yourModel = mongoose.model(‘yourModel’, YourModelSchema,‘YourModel’); 第三个参数就是你自己定义的collection的名字
不是纯粹的加s吧,reply会转成replies呢…
@SoaringTiger 赞一下
这是 mongoose 干的~,和mongodb无关
跟各个orm的提供商有关,像 sequelize 如果不加干预也会对表加‘s
@SoaringTiger schema 里加也可以
new mongoose.Schema(define, options) // options.collection is the real collection name
CNode 社区为国内最专业的 Node.js 开源技术社区,致力于 Node.js 的技术研究。
我怀疑是mongoose这玩意搞的,它还会把大写转小写。真是自作聪明。
var yourModel = mongoose.model(‘yourModel’, YourModelSchema,‘YourModel’); 第三个参数就是你自己定义的collection的名字
不是纯粹的加s吧,reply会转成replies呢…
@SoaringTiger 赞一下
这是 mongoose 干的~,和mongodb无关
跟各个orm的提供商有关,像 sequelize 如果不加干预也会对表加‘s
@SoaringTiger schema 里加也可以