node_pubsubsql
node.js PubSubSql client library
Connecting
Minimal connection is without any options supplied. In this case, connection is attempted on default path: localhost:7777
.
var pss =client = pss;
Connection options
Options are supplied to createClient
method as an object.
Supported options:
- path Complete server endpoint in format
host:port
, e.g.127.0.0.1:7777
- host Server host, e.g.
127.0.0.1
- port Server port, e.g.
7777
- family Connection type, either
IPv6
orIPv4
. Default is autodetected fromhost
.
Extended example:
var pss =client = pss;
Running commands
All commands are ran using query
command which accepts two parameters: command itself and callback function.
Callback function is triggered when server responds to the query. In case of subscription, callback is called
repeatedly every time new data is published.
Function example:
client;
Subscribing to data
The following example sets up client connection and once the connection is ready it subscribes to changes in Stocks
table
when MarketCap
value is MEGA CAP
.
var pss =client = pss;client;client;client