npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

egg-aliyun-tablestore

v1.1.1

Published

🚚 阿里云表格存储(Tablestore)插件,用于 Egg.js 框架

Readme

egg-aliyun-tablestore

npm version MIT npm

egg-aliyun-tablestore

阿里云表格存储(Tablestore)插件,用于 Egg.js 框架。

目录

介绍

本插件的工作只是将表格存储(Tablestore)官方 Node.js SDK 挂载到 Egg.js 框架上,使其能够被便捷地使用。对于表格存储的内部方法,请查看 官方文档

安装

按照通用的方式使用 npm 下载安装到你的项目下即可,无需全局安装。

安装命令:

$ npm i egg-aliyun-tablestore

使用

在使用前,请确保你已经阅读 Egg.js 框架关于插件文档

下面说明如何配置以及使用插件。

启用插件

config/plugin.js 文件中中声明启用 egg-aliyun-tablestore 插件:

exports.tablestore = {
  /** 是否启用插件,true 为启用,false 为禁用 */
  enable: true,

  /** 指定插件使用的包,为 'egg-aliyun-tablestore' */
  package: 'egg-aliyun-tablestore',
}

config/config.${env}.js 配置各个环境的实例信息。

配置方式

根据实例数量分为 单实例配置多实例配置 两种配置方式,使用上也略有不同。

单实例配置

exports.tablestore = {
  // 单实例配置,注意对象属性名为 client,请将 xxxxxxxxxxxx 替换成实际的内容
  client: {
    /** AccessKey ID,必填 */
    accessKeyId: 'xxxxxxxxxxxx',

    /** AccessKey Secret,必填 */
    accessKeySecret: 'xxxxxxxxxxxx',

    /** endpoint 地址,必填 */
    endpoint: 'xxxxxxxxxxxx',

    /** 实例名称,必填 */
    instancename: 'xxxxxxxxxxxx',

    /** 最大重试次数,默认20次,选填 */
    maxRetries: 20,
  },

  /** 是否挂载到 app 上,默认开启,选填 */
  app: true,

  /** 是否挂载到 agent 上,默认关闭,选填 */
  agent: false,
}

如果你不清楚上述配置项是什么含义或者不知道应该填什么,请 查看官方文档

多实例配置

exports.tablestore = {
  // 多实例配置,注意对象属性名为 clients,底下包含多个对象,一个对象为一个实例,对象的属性名用于后面获取实例
  clients: {
	/** 下面的 ots1 为自定义的实例名,用于后续获取实例,你可以自定义为任意名称 */
    ots1: {
      // 实例内部属性与单实例模式相同
      accessKeyId: 'xxxxxxxxxxxx',
      accessKeySecret: 'xxxxxxxxxxxx',
      endpoint: 'xxxxxxxxxxxx',
      instancename: 'xxxxxxxxxxxx',
      maxRetries: 20,
    },

    ots2: {
      accessKeyId: 'xxxxxxxxxxxx',
      accessKeySecret: 'xxxxxxxxxxxx',
      endpoint: 'xxxxxxxxxxxx',
      instancename: 'xxxxxxxxxxxx',
      maxRetries: 20,
    },
    // ... 其他实例

  },

  /** 所有实例配置的默认值 */
  default: {
    // 多个实例中共同的属性可以抽出来放在这里,一般没必要
  },

  /** 是否挂载到 app 上,默认开启,选填 */
  app: true,

  /** 是否挂载到 agent 上,默认关闭,选填 */
  agent: false,
}

使用说明

单实例模式和多实例模式在使用上存在差异,请查看以下使用方式。

单实例使用方式

单实例下,可以直接访问 apptablestore 属性或者 ots 属性访问实例。( otstablestore 的别名,两者完全一致,建议使用 ots ,因为更简短。)

// callback 方式调用
app.tablestore.listTable({}, function (err, data) {
  if (err) {
    console.log('error:', err)
    return
  }
  console.log('success:', data)
})

// 或者使用 ots 属性访问(下同)
app.ots.listTable({}, function (err, data) {
  if (err) {
    console.log('error:', err)
    return
  }
  console.log('success:', data)
})

// promise 方式调用
async ()=>{
  const data = await app.ots.listTable({})
  console.log(data)
}

多实例使用方式

多实例使用方式和单实例类似,只是 获取实例的方式 变了,原来可以直接访问 app.ots 获取实例,变更为 app.ots.get(otsName) 获取。

const client1 = app.ots.get('ots1')

获取原始类

静态属性、方法调用时,需要获取原始的 TableStore 类,可以使用访问 app.TableStore 来获取。

相关

以下是作者开发的 Egg.js 框架的插件系列,已用于作者的生产项目中,推荐使用。

  • egg-apigw-tracer - ⚡ 适配 API 网关的 HTTP 请求示踪器,用于 Egg.js 框架
  • egg-aliyun-tablestore - 🚚 阿里云表格存储(Tablestore)插件,用于 Egg.js 框架
  • egg-load - 🚀 自动挂载第三方模块至 Egg.js 框架上

作者

我是 inlym ,一个产品经理和全栈开发者。

如果你有任何问题或者建议,欢迎联系我,以下是我的联系方式:

参与

非常欢迎你能够参与这个项目的开发和维护。

你可以通过以下几种方式参与到项目中:

  1. 提建议和需求。对于几句话就能说清楚的建议和需求,你可以直接 提一个 New Issue
  2. Fork 项目,修改代码,然后提交 Pull requests 。(提交前请检查务必通过 ESLint 检查)

许可证

本插件使用 MIT 许可证。