# [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command).set(value: any): [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command)

> 支持端：[小程序](/miniprogram/dev/framework/client-lib/version.md), [云函数](/minigame/dev/wxcloud/reference/changelog-server-sdk), [Web](/minigame/dev/wxcloud/reference/changelog-web-sdk)

更新操作符，用于设定字段等于指定值。

## 参数

### value: any

## 返回值

### [Command](/minigame/dev/wxcloud/reference-sdk-api/database/Command)

## 使用说明

这种方法相比传入纯 JS 对象的好处是能够指定字段等于一个对象

## 示例

```js
// 以下方法只会更新 style.color 为 red，而不是将 style 更新为 { color: 'red' }，即不影响 style 中的其他字段
db.collection('todos').doc('doc-id').update({
  data: {
    style: {
      color: 'red'
    }
  }
})

// 以下方法更新 style 为 { color: 'red', size: 'large' }
db.collection('todos').doc('doc-id').update({
  data: {
    style: _.set({
      color: 'red',
      size: 'large'
    })
  }
})
```
