mongoose,创造一个新的模型

我有型号的产品,他没有问题地添加到分贝“产品”

router.post('/create', function (req, res, next) { console.log(req.body); var newProduct = { title: req.body.name, price: req.body.price, description: req.body.description, quantity: req.body.quantity, // category: req.body.category } var product = new Product(newProduct); product.save(function (err, product) { if (err) { res.status(404).json({ message: 'Can not create this product' }) } else { console.log('added'); res.send(product); } }); }); 

现在我有模型类别我创buildhttp.post和所有工作,但我不知道这个东西发送的东西是保存在数据库mongo

 router.post('/create', function (req, res, next) { var newCategory = { name: req.body.name, description: req.body.description } var category = new Category(newCategory); category.save(function (err, category) { if (err) { res.status(404).json({ message: 'Can not create this category' }) } else { console.log('added'); res.send(category); } }); }); 

有人可以exaplain我吗?

至于mongoose自动将您的模型名称转换为多种forms,它应该是 – 类别

更新:
如果你仍然想要你的单一的命名,你可以尝试这样的事情:

 const Category = mongoose.model('Category ', Category Schema, 'Category ');