Getting data back via postgres connection.
This commit is contained in:
		
							parent
							
								
									44765a46a4
								
							
						
					
					
						commit
						fbfbdd0835
					
				
							
								
								
									
										17
									
								
								server.js
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								server.js
									
									
									
									
									
								
							@ -40,7 +40,22 @@ pg.connect(conString, function(err, client, done) {
 | 
			
		||||
    if(err) {
 | 
			
		||||
        return console.error('error fetching client from pool', err);
 | 
			
		||||
    }
 | 
			
		||||
    done();
 | 
			
		||||
 | 
			
		||||
    var devIndexQry = 
 | 
			
		||||
        "select al.coreId, max(co.coreName) as coreName, max(co.locationDesc) as locationDesc, mpub.MaxPub, al.status as MaxStatus " + 
 | 
			
		||||
        "from Alerts al " + 
 | 
			
		||||
            "inner join (select coreId, max(published_at) as MaxPub from Alerts group by coreId) mpub on al.coreId = mpub.coreId and al.published_at = mpub.MaxPub " + 
 | 
			
		||||
        "left join Cores co on al.coreId = co.coreId " + 
 | 
			
		||||
        "group by al.coreId, mpub.MaxPub, al.status ";
 | 
			
		||||
    client.query(devIndexQry, function(err, result) {
 | 
			
		||||
        //call `done()` to release the client back to the pool
 | 
			
		||||
        done();
 | 
			
		||||
 | 
			
		||||
        if(err) {
 | 
			
		||||
            return console.error('error running query', err);
 | 
			
		||||
        }
 | 
			
		||||
        console.log(result.rows[0].corename);
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
db.serialize(function() {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user