0
我試圖插入陣列貓鼬插入每個陣列
這裏是我的架構:
/**
* Created by root on 12/4/16.
*/
module.exports = function (mongoose) {
var hotPrice = mongoose.Schema({
days: String,
price: String
});
return mongoose.model('hotPrice', hotPrice);
};
這裏是我的路線:
router.route('/createHot')
.get(function (req, res) {
var values = [
{days: 1, price: "63"},
{days: 2, price: "125"},
{days: 3, price: "185"},
{days: 4, price: "250"},
{days: 5, price: "314"},
{days: 6, price: "375"},
{days: 7, price: "425"},
{days: 8, price: "495"},
{days: 9, price: "560"},
{days: 10, price: "620"}
];
mongoose.models.hotPrice(values).insert(function (err, message) {
res.status(200);
});
});
但是我得到以下幾點:
TypeError: mongoose.models.hotPrice(...).insert is not a function
任何人都可以告訴m é如何我可以批量插入這個數組?