AdonisJS API
    Preparing search index...

    Class ReadOnlyValuesStore

    Readonly session store that provides read-only access to session values. Used for sharing session data with templates and other readonly contexts.

    const readOnlyStore = new ReadOnlyValuesStore({ user: 'john', theme: 'dark' })
    const user = readOnlyStore.get('user')
    const hasTheme = readOnlyStore.has('theme')

    Hierarchy (View Summary)

    Index
    • Gets value for a given key

      Parameters

      • key: string | string[]

        The key or key path to retrieve

      • OptionaldefaultValue: any

        Default value if key doesn't exist

      Returns any

      store.get('username', 'guest')
      store.get(['user', 'preferences', 'theme'], 'light')
    • Checks if a value exists. Includes extra guards to check arrays for length.

      Parameters

      • key: string | string[]

        The key or key path to check

      • checkForArraysLength: boolean = true

        Whether to check array length (default: true)

      Returns boolean

      store.has('username')                    // Check if key exists
      store.has(['user', 'roles']) // Check nested key
      store.has('items', false) // Don't check array length
    • Gets all values from the store

      Returns any

      const allData = store.all()
      
    • Returns object representation of values

      Returns any

      const obj = store.toObject()
      
    • Returns the store values as JSON-serializable data

      Returns any

      const json = store.toJSON()
      
    • Returns string representation of the store

      Returns string

      const str = store.toString()