0.4.3 • Published 2 years ago
breakpoint-model-indexer v0.4.3
Breakpoint model Indexer
Created 2021-05-31, @jogitt
package with functions to create indexes for models like breakpoint products, vendors and departments.
Updated - 2021-12-08
- now also works with mixMatches, subDepartments, and families
Usage
can create indexes for products, vendors, and departments from breakpoint export and json files.
- create department index:
// load departments is any function to get an array of appropriate breakpoint data
const departments: IDepartment[] = await loadDepartments()
const departmentIndexer = new DepartmentIndexer();
const departmentIndexes = departmentIndexer.start(departments);
classes:
- DepartmentIndexer()
const d = new DepartmentIndexer();
d.start(departments);
- VendorIndexer()
const v = new VendorIndexer();
v.start(vendors);
- ProductIndexer()
const p = new ProductIndexer();
p.start(products);
using index searches
const itemIndexes: ProductIndexes = productIndexer.start(products);
const nameMatches: number[] = BreakpointIndexSearches.getIndexMatch(itemIndexes.nameIndex, namePattern, "gi");
const itemCodeMatches: number[] = BreakpointIndexSearches.getIndexMatch(itemIndexes.upcIndex, itemCodePattern, "i");
const upcMatches: number[] = BreakpointIndexSearches.getProductUPCMatches(itemIndexes.upcIndex, upcPattern);
const vendorIndexes: VendorIndexes = vendorIndexer.start(vendors);
const vendorNameMatches: number[] = BreakpointIndexSearches.getIndexMatch(vendorIndexes.vendorCodeIndex, vendorNamePattern, "gi");
const departmentIndexes: DepartmentIndexes = departmentIndexer.start(departments);
const departmentNameMatches: number[] = BreakpointIndexSearches.getIndexMatch(departmentIndexes.departmentCodeIndex, departmentNamePattern, "gi");