0.2.1 • Published 10 years ago

node-trans v0.2.1

Weekly downloads
2
License
ISC
Repository
gitlab
Last release
10 years ago

Node-Trans

Provide a simple interface to work with trans from nodejs

Install

npm install --save node-trans

Limitations

Currently not support transinfo because of its returned format is different from sql trans.

API

There are 3 classes exported by this lib:

  1. Client: handle connections to the actual trans server and execute command
  2. Command: create trans commands
  3. Parser: handle outputs from trans server and parse them to JS Objects

Example:

var trans = require('node-trans');

var client = new trans.Client('phoenix', 31005);
var command = new trans.Command('load_ad_info');
var params = trans.Command.Param({
  ad_id: 12
  // sample: trans.Command.MultiParam([1,'hai', 3])
});

// execute it!
client.execute(command, params)
  .then(function (output) {
    console.log(output);
    /*
      {
        status: 'TRANS_OK',
        data: {
          load_ad_info: [
            account_id: '1',
            action_id: '1'
            ad_id: '12'
            //...
          ]
        },
        // if there's some trans error occurs
        error: {
          type: 'TRANS_DATABASE_ERROR',
          message: 'ERROR:  ....'
        }
      }
    */
  })
  .catch(function (ex) {
    // handle connection errors, parse errors
  })
0.2.1

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago