// // RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here // 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; // const ASSETS_DIR = "/pb_hooks/assets"; // const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name); // const id_v = "1".padStart(15, 0); //id_vocabulary // const id_c = "2".padStart(15, 0); //id_connectives // const getId = (id) => id.padStart(15, 0); // generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs` const SAMPLE_NOTI_ARRAY = [ [getId("1"), "EV-004", "2025-05-01", false, "new_job", user_id_admin, { title: "Remote React / React Native Developer" }, "", {}, user_id_admin, "https://www.google.com"], [getId("2"), "EV-003", "2025-05-01", false, "new_job", user_id_admin, { title: "Senior Golang Backend Engineer" }, "", {}, user_id_admin, "https://www.google.com"], [getId("3"), "EV-002", "2025-05-01", false, "new_feature", user_id_admin, {}, "Logistics management is now available", {}, user_id_admin, "https://www.google.com"], [getId("4"), "EV-001", "2025-05-01", false, "new_company", user_id_admin, {}, "", { name: "Stripe" }, user_id_admin, "https://www.google.com"], [getId("5"), "EV-005", "2025-05-01", false, "new_company", user_id_admin, {}, "", { name: "Stripe (without link test)" }, user_id_admin, null], ]; let row_array = SAMPLE_NOTI_ARRAY; dirtyTruncateTable("Notifications"); let lt_collection = $app.findCollectionByNameOrId("Notifications"); for (let i = 0; i < row_array.length; i++) { let noti = row_array[i]; let record = new Record(lt_collection); record.set("id", noti[0]); record.set("NOTI_ID", noti[1]); record.set("created_at", noti[2]); record.set("read", noti[3]); record.set("type", noti[4]); record.set("author", noti[5]); record.set("job", noti[6]); record.set("description", noti[7]); record.set("company", noti[8]); record.set("to_user_id", noti[9]); record.set("link", noti[10]); $app.save(record); } console.log(`060_Notifications done`); }; // TODO: remove me // const dirtyTruncateTable = (COLLECTION_NAME) => { // console.log(`perform dirty method to truncate table "${COLLECTION_NAME}"`); // const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`); // cmd_to_exec.output(); // };