我是Mongoose的新手,在尝试向架构中添加属性时遇到了很多麻烦。我忘了在架构中添加一些密钥,现在当我尝试更新架构时,返回的文档是我删除的旧架构
我尝试在架构上使用add()方法,但该方法无效。我还尝试将配置文件制作成自己的Schema,并让其他UserInfoSchema像profile [ProfileSchema]一样引用它,但该配置无法正常工作。删除数据库无效。
我想添加
profile: {
website: String,
bio: String
}
到下面的架构代码
const userInfoSchema = new Schema({
username: String,
display_image: String,
posts: [{
post_id: String,
post_caption: String,
image: String,
image_id: String,
comments: [{
username: String,
user_id: String,
date: { type: Date, default: Date.now },
comment: String,
user_display_image: String
}],
timestamp: String,
items: [{
category: String,
name: String,
price: String,
stores: Array,
online_link: String,
description: String
}]
}],
other_posts: [{ post_id: String, image: String }],
followers: [Array],
boards: [{
id: String,
name: String,
display_image: String,
user: String,
images: [{
username: String,
post: {
image: String,
image_id: String
}
}]
}],
"notifications": [],
"posts_liked": [{
username: String,
id: String,
post_id: String
}],
"feed": [{
username: String,
id: String,
post_id: String
}]
});
谢谢