-
-
Save yeyuguo/a47430687fd4fe5cb68b98781d0294ad to your computer and use it in GitHub Desktop.
pg-action.js
This file contains 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
exports.randomRow = { | |
name: 'randomFirstName', | |
description: 'I will return a random first name from the users table', | |
outputExample: {}, | |
run: function(api, data, next){ | |
pg.connect(api.config.pg.url, function(error, client, done){ | |
if(error){ return next(error); } | |
var query = 'select * from usersorer by random() limit 1'; | |
client.query(query, function(error, results){ | |
if(error){ return next(error); } | |
data.connection.response.randomFirstName = results.rows[0].firstName; | |
done(); | |
next(); | |
}); | |
}); | |
} | |
}; |
This file contains 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
exports.randomRow = { | |
name: 'randomFirstName', | |
description: 'I will return a random first name from the users table', | |
outputExample: {}, | |
run: function(api, data, next){ | |
pg.connect(api.config.pg.url, function(error, client, done){ | |
if(error){ | |
done(); | |
return next(error); | |
} | |
var query = 'select * from usersorer by random() limit 1'; | |
client.query(query, function(error, results){ | |
if(error){ | |
done(); | |
return next(error); | |
} | |
data.connection.response.randomFirstName = results.rows[0].firstName; | |
done(); | |
next(); | |
}); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment