Created
January 30, 2021 11:39
-
-
Save jinalshah999/acaef8f5411f43612f652d722ba2942d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductMSSql { | |
async getAllProducts() { | |
const res = await global.MSSQLConnection.request() | |
.execute("getAllProducts"); | |
return res.recordset; | |
} | |
async addProduct(prod) { | |
const res = await global.MSSQLConnection.request() | |
.input("product_name", prod.product_name) | |
.input("product_price", prod.product_price) | |
.input("product_description", prod.product_description) | |
.input("product_qty", prod.product_qty) | |
.execute("addProduct"); | |
return res; | |
} | |
async updateProduct(prod) { | |
const res = await global.MSSQLConnection.request() | |
.input("product_id", prod.product_id) | |
.input("product_name", prod.product_name) | |
.input("product_price", prod.product_price) | |
.input("product_description", prod.product_description) | |
.input("product_qty", prod.product_qty) | |
.execute("updateProduct"); | |
return res; | |
} | |
async deleteProduct(id) { | |
const res = await global.MSSQLConnection.request() | |
.input("product_id", id) | |
.execute("deleteProduct"); | |
return res; | |
} | |
} | |
module.exports = new ProductMSSql(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment