Browse Source

Added getType and getBoards

master
rino 3 years ago
parent
commit
90ac22449a
3 changed files with 31 additions and 1 deletions
  1. +15
    -1
      database.js
  2. +14
    -0
      index.js
  3. +2
    -0
      led-dump.sql

+ 15
- 1
database.js View File

@ -12,7 +12,7 @@ class Database {
user: 'ledcontroller',
database: 'led'
}).then(res => {
db = res;
db = res;
resolve()
})
.catch(err => {
@ -94,6 +94,20 @@ class Database {
//return db.execute("DELETE FROM ")
}
getBoards(){
return db.execute("SELECT PK_board as boardID, address from `led`.`board`")
.then(res => {
return res[0]
})
}
getLampTypes(){
return db.execute("SELECT PK_type as typeID, name, channel from `led`.`type`")
.then(res => {
return res[0]
})
}
createLamp(boardID, type, channelMapping, title, description) {
db.execute("SELECT PK_type FROM led.type where `key` LIKE \""+type+"\"")

+ 14
- 0
index.js View File

@ -139,6 +139,20 @@ function initRoutes() {
.catch(()=>{res.sendStatus(500)})
})
app.get('/getBoards', (req, res) => {
db.getBoards()
.then(boards => {
res.send(boards)
})
})
app.get('/getTypes', (req, res) => {
db.getLampTypes()
.then(types => {
res.send(types)
})
})
}

+ 2
- 0
led-dump.sql View File

@ -19,6 +19,8 @@
-- Table structure for table `board`
--
Use `led`;
DROP TABLE IF EXISTS `board`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;

Loading…
Cancel
Save