Created
November 6, 2012 02:32
-
-
Save iToto/4022193 to your computer and use it in GitHub Desktop.
Get all users
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
/** | |
+ \brief readUsers | |
+ | |
+ This function will return all user objects to the client | |
+ | |
+ \author Salvatore D'Agostino | |
+ \date 2012-11-05 20:47 | |
+ \param response The response to return to the client | |
+ \param client (PSQL) PSQL client object | |
+ | |
+ \return JSON ARRAY of all user objects, False otherwise | |
**/ | |
function readUsers(response,client) | |
{ | |
console.log('Getting all users'); | |
var query, result; | |
query = client.query({ | |
name: 'read users', | |
text: "SELECT * from users" | |
}); | |
// return the user retrieved | |
query.on('row', function(row,result) { | |
result.addRow(row); | |
}); | |
console.dir(result); | |
var json = JSON.stringify(result); | |
console.log(json); | |
response.writeHead(200, {'content-type':'application/json', 'content-length':json.length}); | |
response.end(json); | |
}// END function readUsers | |
exports.readUsers = readUsers; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment