egg-tablestore
Install
$ npm i egg-tablestore --save
Usage
// {app_root}/config/plugin.jsexportsTableStore = enable: true package: 'egg-tablestore'; await apptabestore;//orawait ctxtabestore;//If you want to access TableStore module, you can:appTableStoreappTableStoreLong
Configuration
Simple database instance
exportstablestore = // 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 apptabestore;//or apptabestore;
Multiple database instance
exportstablestore = 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 = apptabestore;await client1;//or client1; const client2 = apptabestore;await client2;//or client2;
Questions & Suggestions
Please open an issue here.