Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Language Reference Guide
    • Readme
    • Types in the Nu Language
      • Basic Types
        • Any
        • Boolean
        • Integer
        • Float
        • Filesize
        • Duration
        • Datetime
        • Range
        • String
        • Record
        • List
        • Table
        • Closure
        • Nothing
        • Binary
        • Glob
        • Cell-Path
      • Other Data Types

        • Types that cannot be used to declare variables
          • Path
        • Types which are not declarable
          • Error
          • CustomValue
          • Block
      • Type signatures
      • Commands that interact with types
    • Operators
    • Flow control
      • if/else
      • loop
      • while
      • match
      • try/catch
      • break
      • return
      • continue
    • Filters
      • each and par-each
      • Filters to select subsets of data
      • where and filter
      • Understanding the difference between get and select
    • Custom Commands
    • Declarations
    • Variable Scope
    • Strings and Text Formatting
    • Helpers and debugging commands
    • Pipelines
    • MIME Types for Nushell

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, wrap
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
Edit this page on GitHub
Contributors: NotTheDr01ds, fdncred
Prev
String
Next
List