Skip to content

Instantly share code, notes, and snippets.

@jinalshah999
Created January 30, 2021 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jinalshah999/acaef8f5411f43612f652d722ba2942d to your computer and use it in GitHub Desktop.
Save jinalshah999/acaef8f5411f43612f652d722ba2942d to your computer and use it in GitHub Desktop.
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