- npm install, and check for ts version https://code.visualstudio.com/docs/typescript/typescript-compiling
- give your key & API endpoint to '.env' do not commit this use git ignore principles.
complie with tsc, e.g. tsc script1.ts then run with compiled js file e.g. node script1.js
- calculate the total avg, of order value for all orders in store
- Calculates the total number of sales per product in the store
- Stores the above data in a JSON file in the codes directory
- 'line_item' has a 'product_id' that is null, sales are ignored.
- create/update total_sales metafield on each product found in 'salesdata.json'
- updates metafield with total sales, quanity sold * unit price
- uses Admin GraphQL metafieldSet mutation