2.0.2 • Published 7 years ago

egg-tablestore v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

egg-tablestore

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-tablestore --save

Usage

// {app_root}/config/plugin.js
exports.TableStore = {
  enable: true,
  package: 'egg-tablestore',
};

await app.tabestore.putRow(params);
//or
await ctx.tabestore.putRow(params);
//If you want to access TableStore module, you can:
app.TableStore
app.TableStore.Long

Configuration

Simple database instance

exports.tablestore = {
  // database configuration
  client: {
    accessKeyId: '<your access key id>',
    secretAccessKey: '<your access key secret>',
    stsToken: '<your stsToken>', /*When you use the STS authorization, you need to fill in. ref:https://help.aliyun.com/document_detail/27364.html*/
    endpoint: '<your endpoint>',
    instancename: '<your instance name>'
  },
  // load into app, default is open
  app: true,
  // load into agent, default is close
  agent: false,
};

Usage:

await app.tabestore.putRow(params);
//or
yield app.tabestore.putRow(params);

Multiple database instance

exports.tablestore = {
  clients: {
    // clientId, access the client instance by app.tablestore.get('clientId')
    db1: {
      accessKeyId: '<your access key id>',
      secretAccessKey: '<your access key secret>',
      stsToken: '<your stsToken>', /*When you use the STS authorization, you need to fill in. ref:https://help.aliyun.com/document_detail/27364.html*/
      endpoint: '<your endpoint>',
      instancename: '<your instance name>'
    },
    // ...
  },
  // default configuration for all databases
  default: {

  },

  // load into app, default is open
  app: true,
  // load into agent, default is close
  agent: false,
};

Example

const client1 = app.tabestore.get('db1');
await client1.putRow(params);
//or
yield client1.putRow(params);

const client2 = app.tabestore.get('db2');
await client2.putRow(params);
//or
yield client2.putRow(params);

Questions & Suggestions

Please open an issue here.

License

MIT

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago