如何在猫鼬中像这样无条件地更新多个文档? 有可能吗?
运行此代码后,没有任何变化。
const schema = new mongoose.Schema({ name: { type: String, unique: true } });
const Customer = mongoose.model('Customer', schema);
await new Customer({ name: 'john', profile: { age: 23 } }).save();
await new Customer({ name: 'jack', profile: { age: 33 } }).save();
let customers = await Customer.find();
console.log({ customers });
customers[0].profile.age = 20;
const y = await Customer.updateMany(customers);
console.log({ y });