Преглед на файлове

fix getting and assigning the created host id

Pouria Ezzati преди 1 година
родител
ревизия
e037cba4ea
променени са 1 файла, в които са добавени 2 реда и са изтрити 3 реда
  1. 2 3
      server/queries/host.queries.js

+ 2 - 3
server/queries/host.queries.js

@@ -47,9 +47,8 @@ async function add(params) {
       });
       });
   } else {
   } else {
     // Mysql and sqlite don't support returning but return the inserted id by default
     // Mysql and sqlite don't support returning but return the inserted id by default
-    [id] = await knex("hosts")
-      .insert(newHost)
-      .returning('*');
+    const [createdHost] = await knex("hosts").insert(newHost).returning('*');
+    id = createdHost.id;
   }
   }
 
 
   // Query domain instead of using returning as sqlite and mysql don't support it
   // Query domain instead of using returning as sqlite and mysql don't support it