Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- v8
- v7
- v6
script: npm test && npm run integration-test
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# mssql-component
MSSQL Component component for the [elastic.io platform](http://www.elastic.io "elastic.io platform")

![image](https://cloud.githubusercontent.com/assets/56208/22904377/89b611c4-f23c-11e6-8b5d-783d62cf5caf.png)

![image](https://user-images.githubusercontent.com/56208/29715706-b4930bdc-89a8-11e7-8a0d-969959d26dd6.png)

## Before you Begin

Expand All @@ -26,6 +25,9 @@ other types of configuration parameters are also supported, more infromation and
### SELECT Trigger and Action

With this action you may fetch data out of the database, e.g. using ``SELECT`` statement.

![image](https://user-images.githubusercontent.com/56208/29715706-b4930bdc-89a8-11e7-8a0d-969959d26dd6.png)

This trigger & action has no limitations on the number of rows so you may expect to get all of these
via sequential fetching that is implemented within the node.js ``mssql`` driver.

Expand All @@ -39,7 +41,7 @@ select * from Leads where Created >= '%%EIO_LAST_POLL%%'

### INSERT/DELETE/UPDATE Action

![image](https://cloud.githubusercontent.com/assets/56208/22904204/cef8cb06-f23b-11e6-998f-3fe65ab81540.png)
![image](https://user-images.githubusercontent.com/56208/29715914-9c369ee0-89a9-11e7-89cb-a559f4a8861f.png)

You may use this action to do the operations that are not producing output rows but do the database manipulations,
e.g. ``INSERT``, ``UPDATE`` or ``DELETE`` statements. Internally we use prepared statements, so all incoming data is
Expand Down Expand Up @@ -84,8 +86,8 @@ Component supports dynamic incomig metadata - as soon as your query is in place
No known issues are there yet.

## TODOs
* Support for templating in SELECT query
* Support for BULK upload
* Support for DELETE and UPDATE statements
* Support for binary attachments

## License
Expand Down
34 changes: 20 additions & 14 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@
"title": "SELECT",
"description": "Executes a SELECT statement that fetches potentially multiple database rows from the database",
"main": "./lib/actions/select.js",
"fields": {
"query": {
"label": "SQL Query",
"required": true,
"viewClass": "TextAreaWithNoteView",
"placeholder": "SELECT * FROM films WHERE title LIKE ${'%' + query + '%'}",
"note": "You can use properties of message body as <i>${values}</i> in your query"
"metadata": {
"in": {
"type": "object",
"properties": {
"query": {
"type": "string",
"title": "SQL Query",
"required": true
}
}
}
}
}
Expand All @@ -48,13 +51,16 @@
"description": "Executes a SELECT statement that fetches potentially multiple database rows from the database",
"main": "./lib/actions/select.js",
"type": "polling",
"fields": {
"query": {
"label": "SQL Query",
"required": true,
"viewClass": "TextAreaWithNoteView",
"placeholder": "SELECT * FROM films WHERE title LIKE ${'%' + query + '%'}",
"note": "You can use properties of message body as <i>${values}</i> in your insert or update or delete"
"metadata": {
"in": {
"type": "object",
"properties": {
"query": {
"type": "string",
"title": "SQL Query",
"required": true
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function init(cfg) {
* @param cfg configuration that is account information and configuration field values
*/
function processAction(msg, cfg, snapshot = {}) {
const originalSql = cfg.query;
const originalSql = cfg.query || msg.body.query;
const now = new Date().toISOString();
// Last poll should come from Snapshot, if not it's beginning of time
const lastPoll = snapshot.lastPoll || new Date(0).toISOString();
Expand Down
Loading