skeletons for models and services

This commit is contained in:
Mikayla Dobson
2022-09-23 12:25:56 -05:00
parent 6b4c3658d9
commit c9c1de3521
10 changed files with 39 additions and 49 deletions

0
models/CartItem.js Normal file
View File

13
models/CartModel.js Normal file
View File

@@ -0,0 +1,13 @@
module.exports = class CartModel {
async create(userid) {
}
async findOneByUserId(userid) {
}
async findOneByCartId(cartid) {
}
}

View File

@@ -1,44 +0,0 @@
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() {
}
}

0
models/OrderItem.js Normal file
View File

17
models/OrderModel.js Normal file
View File

@@ -0,0 +1,17 @@
module.exports = class OrderModel {
async create() {
}
async update(data) {
}
async findByUser(userid) {
}
async findByOrderId(orderid) {
}
}

9
models/ProductModel.js Normal file
View File

@@ -0,0 +1,9 @@
module.exports = class ProductModel {
async find() {
}
async findOne(productid) {
}
}

0
services/CartService.js Normal file
View File

View File

@@ -1,5 +0,0 @@
const pgp = require('pg-promise')({ capSQL: true });
module.exports = class ExampleService {
}

0
services/OrderService.js Normal file
View File

View File