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
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ Before you can deploy any code into elastic.io **you must be a registered elasti

### Authentication

You may use following URI:
You may use following properties to configure a connection:

```
mssql://username:password@localhost:1433/database?encrypt=true
```
![image](https://user-images.githubusercontent.com/40201204/41356042-97e26406-6f2b-11e8-88fb-11cba846d143.png)

other types of configuration parameters are also supported, more infromation and samples you can find [here](https://www.npmjs.com/package/mssql#formats)

Expand All @@ -33,7 +31,7 @@ via sequential fetching that is implemented within the node.js ``mssql`` driver.

#### Polling

Comopnent will remember last execution timestamp and let you build queries on it:
Component will remember last execution timestamp and let you build queries on it:

```sql
select * from Leads where Created >= '%%EIO_LAST_POLL%%'
Expand Down
40 changes: 37 additions & 3 deletions component.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,45 @@
"description": "elastic.io integration component for Microsoft SQL Server",
"credentials": {
"fields": {
"uri": {
"label": "Connection URI",
"server": {
"label": "Server (you can use 'host\\\\instance' to connect to named instance)",
"required": true,
"viewClass": "TextFieldView",
"placeholder": "mssql://username:password@localhost/database"
"placeholder": "localhost"
},
"port": {
"label": "Port (don't set when connecting to named instance)",
"required": false,
"viewClass": "TextFieldView",
"placeholder": "1433"
},
"database": {
"label": "Database Name",
"required": true,
"viewClass": "TextFieldView",
"placeholder": "database"
},
"encrypt": {
"label": "Encrypt (check this option if you're using Windows Azure)",
"viewClass": "CheckBoxView"
},
"domain": {
"label": "Domain (driver will connect to SQL Server using domain login)",
"required": false,
"viewClass": "TextFieldView",
"placeholder": "domain"
},
"username": {
"label": "Username",
"required": true,
"viewClass": "TextFieldView",
"placeholder": "username"
},
"password": {
"label": "Password",
"required": true,
"viewClass": "PasswordFieldView",
"placeholder": "password"
}
}
},
Expand Down
14 changes: 13 additions & 1 deletion lib/actions/insert.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,19 @@ const VARS_REGEXP = /@([\w_$][\d\w_$]*(:(string|boolean|date|number|bigint|float
* @returns {Promise}
*/
function init(cfg) {
const conString = cfg.uri;
const conString = 'mssql://'
+ encodeURIComponent(cfg.username)
+ ':'
+ encodeURIComponent(cfg.password)
+ '@'
+ cfg.server
+ ((cfg.port) ? ':' + cfg.port : '')
+ ((cfg.instance) ? '/' + cfg.instance : '')
+ '/'
+ cfg.database
+ ((cfg.domain) ? '?domain=' + cfg.domain + '&encrypt=' + cfg.encrypt
: '?encrypt=' + cfg.encrypt);
console.log(conString);
return co(function* gen() {
console.log('Connecting to the database');
const connection = new cosql.Connection(conString);
Expand Down
13 changes: 12 additions & 1 deletion lib/actions/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ let connection;
* @param cfg
*/
function init(cfg) {
const conString = cfg.uri;
const conString = 'mssql://'
+ encodeURIComponent(cfg.username)
+ ':'
+ encodeURIComponent(cfg.password)
+ '@'
+ cfg.server
+ ((cfg.port) ? ':' + cfg.port : '')
+ ((cfg.instance) ? '/' + cfg.instance : '')
+ '/'
+ cfg.database
+ ((cfg.domain) ? '?domain=' + cfg.domain + '&encrypt=' + cfg.encrypt
: '?encrypt=' + cfg.encrypt);
return co(function* gen() {
console.log('Connecting to the database');
connection = new cosql.Connection(conString);
Expand Down
Loading