Sfoglia il codice sorgente

fix getting and assigning the id of the created domain

Pouria Ezzati 1 anno fa
parent
commit
0c0a3de1b1
1 ha cambiato i file con 2 aggiunte e 3 eliminazioni
  1. 2 3
      server/queries/domain.queries.js

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

@@ -51,9 +51,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("domains")
-      .insert(newDomain)
-      .returning("id");
+    const [createdDomain] = await knex("domains").insert(newDomain).returning("id");
+    id = createdDomain.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