这是我的模特
var tripSchema = new mongoose.Schema({
image: String,
location: String,
date: Date,
description: String,
author: {
id: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
},
pictures: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Picture"
}
]
});
var pictureSchema = new mongoose.Schema({
image: String,
location: String,
description: String,
author: {
id: {
type: mongoose.Schema.Types.ObjectId,
ref: "User"
},
username: String
}
});
我使用Pictute.create()可以很好地创建1个文档。现在,我想一次添加多个文档。 我正在尝试将相同的代码放入循环中,但不起作用。 我还有其他方法可以做到吗?