๐Ÿ“ฆ Anthonyzou / crate-client

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/Anthonyzou/crate-client.git
HTTPS git clone https://github.com/Anthonyzou/crate-client.git
SSH git clone git@github.com:Anthonyzou/crate-client.git
CLI gh repo clone Anthonyzou/crate-client
Anthony Ou Anthony Ou updated readme markdown 9cde8d4 9 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ test
๐Ÿ“„ .gitignore
๐Ÿ“„ docker-compose.yml
๐Ÿ“„ index.js
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ README.md

API

crate-client

var crateClient = require('crate-client', options)
var client = new crateClient('localhost:4200')
client = new crateClient(['localhost:4200', 'localhost:4400'])

client.query('select * from users where ? = id', [42], callback)

Options for http endpoints - checkout poolee

{
  maxPending: 1000,       // maximum number of outstanding request to allow
  maxSockets: 20,         // max sockets per endpoint Agent
  timeout: 60000,         // request timeout in ms
  resolution: 1000,       // timeout check interval (see below)
  keepAlive: false,       // use an alternate Agent that does http keep-alive properly
  ping: undefined,        // health check url
  pingTimeout: 2000,      // ping timeout in ms
  retryFilter: undefined, // see below
  retryDelay: 20,         // see below
  maxRetries: 5,          // see below
  name: undefined,        // optional string
  agentOptions: undefined// an object for passing options directly to the Http Agent
}

Usage

removeConditionals

Remove checks for the callback being a function. And maybe other conditionals in the future.

client.exec

Send a query that does not include arguments

client.query('select * from users where 42 = id', callback)

client.query

Send a query that does have arguments, in the form of an array

client.query('select * from users where ? = id', [42], callback)

Testing

  • Start up crate with docker-compose up
  • Install mocha npm -g i mocha
  • run testing with npm test