Supported platforms: Mini Program, Cloud Functions, Web
The update operator, used to set a field to a specified value.
Parameters
value: any
Return Values
Command
Usage Instructions
The benefit of this method over passing a plain JS object is that it allows specifying a field as an object.
Example
// The following method only updates style.color to red, rather than updating the entire style object to { color: 'red' }, leaving other fields within style unaffected.
db.collection('todos').doc('doc-id').update({
data: {
style: {
color: 'red'
}
}
})
// The following method updates style to { color: 'red', size: 'large' }
db.collection('todos').doc('doc-id').update({
data: {
style: _.set({
color: 'red',
size: 'large'
})
}
})