Last active
June 21, 2017 18:53
-
-
Save bdunnette/49b37ca269f904b9fa993fadd2980101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT TOP 100 * | |
| FROM [Aperio].[dbo].[Specimen] Specimen | |
| INNER JOIN [Aperio].[dbo].[Slide] Slide | |
| ON Slide.ParentId=Specimen.Id | |
| INNER JOIN [Aperio].[dbo].[Image] Image | |
| ON Image.ParentId=Slide.Id | |
| WHERE Specimen.ColumnPublishToWeb2 = 'TRUE' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('dotenv').config() | |
| const sql = require('mssql/msnodesqlv8') | |
| var jackrabbit = require('jackrabbit'); | |
| // Get the URL from ENV or default to localhost | |
| var url = process.env.CLOUDAMQP_URL || "amqp://localhost"; | |
| console.log(url); | |
| // Connect to CloudAMQP | |
| var rabbit = jackrabbit(url); | |
| var exchange = rabbit.default(); | |
| var hello = exchange.queue({ name: 'example_queue', durable: true }); | |
| const config = { | |
| user: 'Aperio', | |
| // password: '...', | |
| server: 'localhost', // You can use 'localhost\\instance' to connect to named instance | |
| database: 'Aperio', | |
| trustedConnection: true, | |
| connectionString: 'Driver={SQL Server Native Client 10.0};Server={localhost};Database={Aperio};Trusted_Connection={yes}', | |
| // options: { | |
| // encrypt: true // Use this if you're on Windows Azure | |
| // } | |
| } | |
| sql.connect(config, err => { | |
| // ... error checks | |
| console.log(err); | |
| // Query | |
| var req = new sql.Request(); | |
| // console.log(req); | |
| //req.query("SELECT * FROM Aperio.dbo.Specimen WHERE ColumnPublishToWeb2 = 'TRUE'", (err, result) => { | |
| req.query("SELECT TOP 100 * FROM [Aperio].[dbo].[Specimen] Specimen INNER JOIN [Aperio].[dbo].[Slide] Slide ON Slide.ParentId=Specimen.Id INNER JOIN [Aperio].[dbo].[Image] Image ON Image.ParentId=Slide.Id WHERE Specimen.ColumnPublishToWeb2 = 'TRUE'", (err, result) => { | |
| // ... error checks | |
| console.log(err); | |
| console.dir(result); | |
| result.recordset.forEach(function(record){ | |
| console.log(record); | |
| exchange.publish({ msg: record }, { key: 'example_queue' }); | |
| }) | |
| }) | |
| }) | |
| sql.on('error', err => { | |
| // ... error handler | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment