Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var express = require('express');
- var app = express();
- //Mysql
- var mysql = require('mysql');
- var connection = mysql.createConnection({
- host : '69.162.72.194',
- user : 'minecor1_ranks',
- password : 'taco1998',
- database : 'minecor1_devranks'
- });
- app.get('/', function(req, res){
- //Define the array
- var userArray = [];
- //Connect to DB
- connection.connect();
- //Query DB
- connection.query('SELECT child,parent FROM permissions_inheritance;', function(err, rows, fields) {
- if (err) throw err;
- //Set array to array of object with UUID and rank in them.
- userArray = rows;
- //Loop through array get rid of ranks.
- for (var i = 0; i < userArray.length; i++) {
- var x = userArray[i].child.split('');
- console.log(x[0]);
- if(x[0] == x[0].toUpperCase() && isNaN(x[0])){
- userArray.splice(i, 1);
- if(userArray[i]){
- console.log('found', userArray[i].child);
- }
- }
- if(i == userArray.length - 1){
- res.send(userArray);
- }
- };
- });
- });
- app.listen(3000);
- package json:
- {
- "name": "MineCorner",
- "version": "1.0.0",
- "description": "",
- "main": "index.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies": {
- "body-parser": "^1.13.2",
- "express": "^4.13.1",
- "mysql": "^2.8.0"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement