Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. var express = require('express');
  2. var app = express();
  3.  
  4. //Mysql
  5. var mysql = require('mysql');
  6. var connection = mysql.createConnection({
  7. host : '69.162.72.194',
  8. user : 'minecor1_ranks',
  9. password : 'taco1998',
  10. database : 'minecor1_devranks'
  11. });
  12.  
  13.  
  14. app.get('/', function(req, res){
  15. //Define the array
  16. var userArray = [];
  17. //Connect to DB
  18. connection.connect();
  19.  
  20. //Query DB
  21. connection.query('SELECT child,parent FROM permissions_inheritance;', function(err, rows, fields) {
  22. if (err) throw err;
  23. //Set array to array of object with UUID and rank in them.
  24. userArray = rows;
  25.  
  26. //Loop through array get rid of ranks.
  27. for (var i = 0; i < userArray.length; i++) {
  28. var x = userArray[i].child.split('');
  29. console.log(x[0]);
  30. if(x[0] == x[0].toUpperCase() && isNaN(x[0])){
  31. userArray.splice(i, 1);
  32. if(userArray[i]){
  33. console.log('found', userArray[i].child);
  34. }
  35. }
  36. if(i == userArray.length - 1){
  37.  
  38. res.send(userArray);
  39. }
  40. };
  41. });
  42. });
  43.  
  44. app.listen(3000);
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. package json:
  52.  
  53. {
  54. "name": "MineCorner",
  55. "version": "1.0.0",
  56. "description": "",
  57. "main": "index.js",
  58. "scripts": {
  59. "test": "echo \"Error: no test specified\" && exit 1"
  60. },
  61. "author": "",
  62. "license": "ISC",
  63. "dependencies": {
  64. "body-parser": "^1.13.2",
  65. "express": "^4.13.1",
  66. "mysql": "^2.8.0"
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement