你的后模式看起来很奇怪。
这有什么意义?
post集合已经是posts的“数组”。
// Perhaps you are looking for something like this.
const PostSchema = new mongoose.Schema({
title: String,
content: String,
level: Number,
footer: String,
author: ObjectId,// who wrote the post
comments: [{
user: ObjectId,
comment: String
}],
... createdAt, updatedAt etc
});
例如
等待Post.create({posts:req.body});