pusudb-connector
Create a connector for the pusudb-framework.
Framework: https://www.npmjs.com/package/pusudb
Define the configuration and open the connection. When a key is subscribed, then each event will be fired according the meta. Check the pusudb docs for the metas.
Installing
npm install pusudb-connector --save
Use
Options
- key of the pusudb-connector-instance
- db is the db-name where the pusudb stores the data
- url of the pusudb
- login-object of the pusudb-use-auth-jwt
- subscribeWhenOpen if true, then the key will be subscribed when the connection is open
const Connector = // Create instancelet connectComponent = key : 'sensor:rapport' db : 'component' url : '192.168.178.20:3000/api' login : null // or { email : '', password: '' } when login required, check props in pusudb-configuration subscribeWhenOpen : true heartbeat : 30000 // default or set the same value like in pusudb // Create connection connectComponent // Fired when the connection is openconnectComponent // Fired when the db entry has changed by putconnectComponent // Fired when the db entry has changed by updateconnectComponent // Fired when the db entry has changed by deleteconnectComponent // Fired when the db entry has changed by batchconnectComponent // Fired when the db entry has changed by batchconnectComponent // Fired when the websocket is closed. It will try to reconnet every 10s.// Change interval connectComponent.reconnectInterval = ...msconnectComponent // Fired when an error occurredconnectComponent connectComponentws /********************************************************/// QUERY API // webscoket Push data direct to the defined db in cfgconnectComponent// http Pull data direct from the defined db in cfg,connectComponent // http Get query arguments = db, meta, params, callbackconnectComponent // Post query arguments = db, meta, json-dataconnectComponent // Websocket query arguments = db, meta, json-dataconnectComponent
Authors
- Yannick Grund - Initial work - yamigr
License
This project is licensed under the MIT License