attempted to refactor db seed, still needs more updating

This commit is contained in:
Mikayla Dobson
2022-11-26 18:26:32 -06:00
parent 9bd1704da9
commit 9d0c8a8782
22 changed files with 340 additions and 68 deletions

View File

@@ -1,5 +1,6 @@
import { IIngredient } from "../schemas";
import pool from "../db";
import now from "../util/now";
export class Ingredient {
async getAll() {
@@ -28,9 +29,9 @@ export class Ingredient {
try {
const statement = `
INSERT INTO recipin.ingredient
(name, description)
VALUES ($1, $2) RETURNING *`;
const values = [data.name, data.description];
(name, description, datecreated)
VALUES ($1, $2, $3) RETURNING *`;
const values = [data.name, data.description, data.datecreated || now];
const result = await pool.query(statement, values);
if (result.rows.length) return result.rows[0];
return null;