updates to db seed, ts definitions
This commit is contained in:
37
server/models/collection.ts
Normal file
37
server/models/collection.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user