keyv-azuretable
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

keyv

Keyv-AzureTable Test npm

An Azure Table adapter for Keyv

Install

npm install keyv-azuretable

Usage

const Keyv = require('keyv')
const { AzureTableAdapter } = require('keyv-azuretable')

const azTableOption = {
  connectionString: '', // connection string for your storage account
  tableName: '', // name of the table
  namespace: '', //optional (it's the partition key for the table, if it's empty it will be generated for you)
  clientOptions: {}, // optional (azure-table TableClient-specific options. See note below.)
}

const noNsAzTable = new AzureTableAdapter()
await noNsAzTable.createTable() // if the table is not created, you can use `createTable` to create the table. If the table already exists, this method will not throw/fail.
const config = noNsAzTable.getKeyvConfig()
// config = {store: azTableAdatpr, namespace: `keyvns-${nanoid()}`}
const keyv = new Keyv(config)

const usersAzTable = new AzureTableAdapter({
  ...azTableOption,
  namespace: 'users',
})
// userAzTable = {store: azTableAdapter, namespace: 'users'}
const usersKeyv = new Keyv(usersAzTable)

//set
await keyv.set('foo', 'bar', 6000) //Expiring time is optional (milliseconds)

//get
const obj = await keyv.get('foo')

//delete
await keyv.delete('foo')

//clear
await keyv.clear()

Note: clientOptions is the TableClient-specific TableServiceClientOptions object. (See Azure Docs for more details)

Readme

Keywords

none

Package Sidebar

Install

npm i keyv-azuretable

Weekly Downloads

2

Version

1.2.1

License

MIT

Unpacked Size

9.97 kB

Total Files

5

Last publish

Collaborators

  • howlowck