updates to cart section of api
This commit is contained in:
@@ -4,7 +4,7 @@ const pgp = require('pg-promise')({ capSQL: true });
|
||||
module.exports = class CartModel {
|
||||
async create(userid) {
|
||||
try {
|
||||
const statement = pgp.helpers.insert(userid, null, 'carts') + 'RETURNING *';
|
||||
const statement = pgp.helpers.insert(userid, null, 'cart') + 'RETURNING *';
|
||||
const result = await db.query(statement);
|
||||
if (result.rows.length) return result.rows[0];
|
||||
return null;
|
||||
@@ -15,7 +15,7 @@ module.exports = class CartModel {
|
||||
|
||||
async findOneByUserId(userid) {
|
||||
try {
|
||||
const statement = `SELECT * FROM carts WHERE userid = $1`;
|
||||
const statement = `SELECT * FROM cart WHERE userid = $1`;
|
||||
const filter = [userid];
|
||||
const result = await db.query(statement, filter);
|
||||
if (result.rows.length) return result.rows[0];
|
||||
@@ -27,7 +27,7 @@ module.exports = class CartModel {
|
||||
|
||||
async findOneByCartId(cartid) {
|
||||
try {
|
||||
const statement = `SELECT * FROM carts WHERE id = $1`;
|
||||
const statement = `SELECT * FROM cart WHERE id = $1`;
|
||||
const filter = [cartid];
|
||||
const result = await db.query(statement, filter);
|
||||
if (result.rows.length) return result.rows[0];
|
||||
@@ -36,4 +36,20 @@ module.exports = class CartModel {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async updateCart(data) {
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async insertNewItem(data) {
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user