Преглед изворни кода

Server: PUT /services/{serverId} - SQLITE_RANGE: column index out of range; ID zurückgeben nach Insert

Christian Kahlau пре 3 година
родитељ
комит
e7d03e3108
1 измењених фајлова са 2 додато и 1 уклоњено
  1. 2 1
      server/src/ctrl/database.class.ts

+ 2 - 1
server/src/ctrl/database.class.ts

@@ -335,6 +335,7 @@ export class Database extends SQLiteController {
       } else {
         // INSERT
         const res = await this.run('INSERT INTO HealthCheckConfig(ServerID, Type, Title) VALUES(?, ?, ?);', [serverID, 'http', conf.title]);
+        conf.id = res.lastID;
 
         const insCheckValues = conf.checks.map(c => [res.lastID, 'regexp', 'check', c]);
         await this.run(
@@ -344,7 +345,7 @@ export class Database extends SQLiteController {
           [
             ...[res.lastID, 'text', 'url', conf.url],
             ...[res.lastID, 'number', 'interval', conf.interval],
-            ...conf.checks.reduce((res, arr) => [...res, ...arr], [] as any[])
+            ...conf.checks.reduce((ret, check) => [...ret, res.lastID, 'regexp', 'check', check], [] as any[])
           ]
         );
       }