Record
Description: | The foundational associative map. Holds key-value pairs, which associate string keys with various data values. |
Annotation: | record |
Literal syntax: | See below |
Casts: | into record |
See Also: | Working with Records |
Navigating and Accessing Structured Data | |
Types of Data - Records |
Language Notes
- The keys maintain the order of insertion or the order defined in a record literal.
- Keys are guaranteed to be unique. Inserting the same key twice will keep only the last insertion or definition.
(TBD: complex hashable/equality checkable keys)
Record-Literal Syntax
Record syntax is very similar to objects in JSON. However, commas are not required to separate values when Nushell can easily distinguish them. The key-value pairs of a record may be delimited by:
Commas
> {name: "Sam", rank: 10} ╭──────┬─────╮ │ name │ Sam │ │ rank │ 10 │ ╰──────┴─────╯
Spaces (when unambiguous):
> {name: "Sam" rank: 10} ╭──────┬─────╮ │ name │ Sam │ │ rank │ 10 │ ╰──────┴─────╯
Line breaks:
> { name: "Sam" rank: 10 } ╭──────┬─────╮ │ name │ Sam │ │ rank │ 10 │ ╰──────┴─────╯
Common commands that can be used with record
Since the record data type is foundational to Nushell's structured nature, many commands use records as inputs or as parameters. See the list of commands for tables as many of those also take records.
Here are a few commands that use records:
get
insert
merge
update
upsert