更新集合中的一批记录。
方法定义
该方法的定义如下:
updateMany(filter: object, update: object, options?: object): Promise<MongoResult>
请求参数
该方法接收 4 个参数,其定义如下:
字段名 | 类型 | 必填 | 说明 |
---|---|---|---|
filter | Object | 是 | 过滤条件。 |
update | Object | 是 | 更新的文档 |
options | Object | 否 | 控制项 |
options.upsert | Boolean | 否 | 不匹配时是否直接插入文档。默认值:false。 |
示例
mpserverless.db.collection('users').updateMany({
name: 'jerry'
}, {
$set: {
age: 10
}
})
.then(res => {})
.catch(console.error)
在文档使用中是否遇到以下问题
更多建议
匿名提交