backend overhaul

This commit is contained in:
Mikayla Dobson
2022-09-22 13:14:43 -05:00
parent 905b3266a3
commit 75ebb5e43d
9 changed files with 276 additions and 16 deletions

44
models/ExampleModel.js Normal file
View File

@@ -0,0 +1,44 @@
const db = require('../db/Pool');
module.exports = class ExampleModel {
async create() {
}
async update() {
}
async findOneByEmail(email) {
try {
const statement = `SELECT * FROM example WHERE email = $1`;
const values = [email];
const result = await db.query(statement, values);
if (result.rows?.length) {
return result.rows[0];
}
return null;
} catch(e) {
throw new Error(e);
}
}
async findAll() {
try {
const statement = "SELECT * FROM example";
const result = await db.query(statement);
if (result.rows?.length) return result.rows;
return null;
} catch(e) {
throw new Error(e);
}
}
async deleteOne() {
}
}