name: String,
age: Number,
email: String,
password: String,
hobbies: [String]
});
// 使用规则创建集合...const User = mongoose.model('User', userSchema);
// 查找到一条文档并且删除
// 返回删除的文档
// 如何查询条件匹配了多个文档 那么将会删除第一个匹配的文档...即删除所有文档
User.deleteMany({}).then(result => console.log(result))
// 更新单个
User.updateOne({查询条件}, {要修改的值}...).then(result => console.log(result))
// 更新多个
User.updateMany({查询条件}, {要更改的值}).then(result => console.log...name: String,
age: Number,
email: String,
password: String,
hobbies: [String]
});
// 使用规则创建集合