upsert for filters> upsert {flags} (field) (replacement value)
field: the name of the column to update or insertreplacement value: the new value to give the cell(s), or a closure to create the value| input | output | 
|---|---|
| list<any> | list<any> | 
| record | record | 
| table | table | 
Update a record's value
> {'name':'nu', 'stars':5} |upsertname'Nushell'
╭───────┬─────────╮
│name│Nushell│
│stars│5│
╰───────┴─────────╯
Update each row of a table
> [[namelang]; [Nushell''] [Reedline'']] |upsertlang'Rust'
╭───┬──────────┬──────╮
│# │   name   │ lang │
├───┼──────────┼──────┤
│0│Nushell│Rust│
│1│Reedline│Rust│
╰───┴──────────┴──────╯
Insert a new entry into a single record
> {'name':'nu', 'stars':5} |upsertlanguage'Rust'
╭──────────┬──────╮
│name│nu│
│stars│5│
│language│Rust│
╰──────────┴──────╯
Use in closure form for more involved updating logic
> [[countfruit]; [1'apple']] |enumerate|upsertitem.count {|e| ($e.item.fruit|str length) +$e.index } |getitem
╭───┬───────┬───────╮
│# │ count │ fruit │
├───┼───────┼───────┤
│0│5│apple│
╰───┴───────┴───────╯
Upsert an int into a list, updating an existing value based on the index
> [123] |upsert02
╭───┬───╮
│0│2│
│1│2│
│2│3│
╰───┴───╯
Upsert an int into a list, inserting a new value based on the index
> [123] |upsert34
╭───┬───╮
│0│1│
│1│2│
│2│3│
│3│4│
╰───┴───╯
    Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
    https://www.nushell.sh/commands/docs/upsert.html