Files
recipe-manager/server/models/collection.ts
2022-11-19 10:55:44 -06:00

37 lines
948 B
TypeScript

import { ICollection } from "../schemas";
import pool from "../db";
export class Collection {
async getOne(id: string) {
try {
const statement = `SELECT * FROM recipin.collection WHERE id = $1`;
const values = [id];
const result = await pool.query(statement, values);
return result;
} catch (e: any) {
throw new Error(e);
}
}
async getAll() {
// requires clearance
try {
const statement = `SELECT * FROM recipin.collection`;
const result = await pool.query(statement);
return result;
} catch (e: any) {
throw new Error(e);
}
}
async post(data: ICollection) {
try {
const statement = `
INSERT INTO recipin.collection
()
`
} catch (e: any) {
throw new Error(e);
}
}
}