2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: update
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
2019-10-03 13:24:28 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Update an existing column to have a new value.
|
2019-10-03 13:24:28 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
2019-10-03 13:24:28 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
```> update (field) (replacement value)```
|
2020-06-23 20:21:47 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Parameters
|
2019-10-03 13:24:28 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `field`: the name of the column to update
|
|
|
|
- `replacement value`: the new value to give the cell(s)
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Update a column value
|
2019-10-03 13:24:28 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo {'name': 'nu', 'stars': 5} | update name 'Nushell'
|
2020-06-23 20:21:47 +02:00
|
|
|
```
|
|
|
|
|
2022-02-20 02:13:33 +01:00
|
|
|
Use in block form for more involved updating logic
|
|
|
|
```shell
|
|
|
|
> echo [[count fruit]; [1 'apple']] | update count {|f| $f.count + 1}
|
|
|
|
```
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Use in block form for more involved updating logic
|
2020-06-23 20:21:47 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> echo [[project, authors]; ['nu', ['Andrés', 'JT', 'Yehuda']]] | update authors { get authors | str collect ',' }
|
2019-10-03 13:24:28 +02:00
|
|
|
```
|