Skip to content

Commit

Permalink
fix: allow DB to create species UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcharlton authored Nov 1, 2022
1 parent 4f5ff9e commit 0322686
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/controllers/species.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { inject } from '@loopback/context';
import { v4 as uuid } from 'uuid';
import {
Count,
CountSchema,
Expand Down Expand Up @@ -149,10 +148,7 @@ export class SpeciesController {
async combine(
@requestBody() request: { combine: number[]; species: Species },
): Promise<void> {
const newSpecies = await this.speciesRepository.create({
...request.species,
uuid: uuid(),
});
const newSpecies = await this.speciesRepository.create(request.species);

const updateQuery = `UPDATE trees SET species_id=${
newSpecies.id
Expand All @@ -174,10 +170,7 @@ export class SpeciesController {
},
})
async create(@requestBody() species: Species): Promise<Species> {
return await this.speciesRepository.create({
...species,
uuid: uuid(),
});
return await this.speciesRepository.create(species);
}

@del('/species/{id}', {
Expand Down

0 comments on commit 0322686

Please sign in to comment.