ProductService.js 564 B

12345678910111213141516171819202122232425
  1. const knex = require('../models/database');
  2. class ProductService {
  3. constructor(url){
  4. this.url = url
  5. }
  6. present(data) {
  7. let { id, name, price, quantity, pages, printers, description, shortdescription } = data;
  8. return { id, name, price, quantity, pages, printers, description, shortdescription };
  9. }
  10. verify(product) {
  11. console.log(product);
  12. return knex('Products').where('id',product).select('*')
  13. .then((res) => {
  14. if (res.length === 0) {
  15. throw Error('No such product!');
  16. }
  17. return res;
  18. });
  19. }
  20. }
  21. module.exports = new ProductService();