// // RULES: // this is not a normal nodejs engine, // it is a nodejs provided by golang, // so fakerjs cannot be used here // use vscode extensions 'Gruntfuggly.align-mode' to align comma // const config = require("/pb_hooks/seed/config.js"); const utils = require("/pb_hooks/seed/utils.js"); // module.exports = ($app) => { const { CR_cat_id_news, CR_cat_id_technology, user_id_admin, user_id_test_teacher_1 } = config; const { getId, getAsset, dirtyTruncateTable } = utils; // generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs` const SAMPLE_BILLING_ADDRESS_CSV = ` Central African Republic , Arizona , Winfieldburgh , 92017-8004, 1838 Willa Freeway , Suite 307 Iraq , Nevada , Casa Grande , 83831-3843, 6984 Alberto Radial , Suite 154 Grenada , Georgia , New Brodyfort , 18887-7075, 493 Pfannerstill Meadow, Apt. 358 Australia , North Carolina, Fort Jerrell , 14211 , 1763 West Street , Suite 699 Reunion , New York , Kayton , 82048-0645, 636 Angel Junction , Apt. 361 Heard Island and McDonald Islands, Wisconsin , Jalenbury , 75732-7013, 669 Sven Trail , Suite 409 Israel , Maryland , East Allenmouth, 21779 , 6070 W Grand Avenue , Suite 448 Canada , Michigan , Lafayette , 90430-8775, 430 Orland Place , Suite 891 South Georgia , Colorado , Lake Isaias , 26025-5909, 143 Kautzer Unions , Apt. 752 Mali , Illinois , Stammburgh , 92318 , 7669 Jude Drive , Apt. 594 `; const SAMPLE_BILLING_ADDRESS_AA = SAMPLE_BILLING_ADDRESS_CSV.trim() .split("\n") .map((r) => r.split(",").map((c) => c.trim())); let row_array = SAMPLE_BILLING_ADDRESS_AA; dirtyTruncateTable("billingAddress"); let ba_collection = $app.findCollectionByNameOrId("billingAddress"); for (let i = 0; i < row_array.length; i++) { let ba = row_array[i]; let record = new Record(ba_collection); record.set("id", getId(i.toString())); record.set("country", ba[0]); record.set("state", ba[1]); record.set("city", ba[2]); record.set("zipCode", ba[3]); record.set("line1", ba[4]); record.set("line2", ba[5]); $app.save(record); } console.log(`062_billingAddress done`); };