Node.js - kv.keys()

Return an async iterable of keys in the store.

import { kv } from '@nitric/sdk'

const profiles = kv('profiles').allow('get')

const keys = profiles.keys()

for await (const key of keys) {
  // do something with the key
}

Parameters

  • Name
    prefix
    Optional
    Optional
    Type
    string
    Description

    The prefix to filter keys by, if not provided all keys will be returned.

Examples

Get all keys from a key value store

import { kv } from '@nitric/sdk'

const profiles = kv('profiles').allow('get')

const keys = profiles.keys()

for await (const key of keys) {
  // do something with the key
}

Get keys filtered by prefix from a key value store

import { kv } from '@nitric/sdk'

const profiles = kv('profiles').allow('get')

const keys = profiles.keys('subprofile:')

for await (const key of keys) {
  // do something with the key
}