Skip to content

Added functions to get category and products

Patrick Riley requested to merge dbgetters into master

Created by: rileyp2000

IMPORTANT You will need to uncomment the following block in main.ts to populate some sample values on the first AND ONLY THE FIRST time you start the app. Otherwise, you will get errors.

122  // if (isDebug) {
  //   insertFakeData(db);
  // }

This adds three functions to use for getting information between the DB and the frontend. From the frontend perspective, you will call them using this syntax:

window.electron.dbQuery('some SQL statement') // This one is only for workshopping and temporary use, will not be in final version of the app, returns promise

// Types introduced for the following functions:
type Category = {
  categoryId: number;
  name: string;
  taxRate: number;
};

type Product = {
  productId: number;
  name: string;
  unitPrice: number;
  category: Category;
};



window.electron.getProduct(id) // id is a number, and this returns a Promise of the Project Object type
window.electron.getCateogry(id) // id is a number, and this returns a Promise of the CategoryObject type

Merge request reports