From 99ee2f9fc3fcb2c5945e98be28fcad538eec9ea0 Mon Sep 17 00:00:00 2001 From: louiscklaw Date: Sun, 11 May 2025 17:29:19 +0800 Subject: [PATCH] ``` add admin user ID to seed config and update notification relations ``` --- .../pb_hooks/seed/007_Users_admin.js | 4 +- .../pb_hooks/seed/060_Notifications.js | 15 +++--- 002_source/pocketbase/pb_hooks/seed/config.js | 3 ++ .../pocketbase/pb_hooks/seed/schema.json | 49 +++++++++++++++---- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/002_source/pocketbase/pb_hooks/seed/007_Users_admin.js b/002_source/pocketbase/pb_hooks/seed/007_Users_admin.js index 214d480..2adb55f 100644 --- a/002_source/pocketbase/pb_hooks/seed/007_Users_admin.js +++ b/002_source/pocketbase/pb_hooks/seed/007_Users_admin.js @@ -2,9 +2,9 @@ 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 } = config; + const { CR_cat_id_news, CR_cat_id_technology, user_id_admin } = config; const { getId, getAsset } = utils; - const ADMIN_USER_ID = getId("999"); + const ADMIN_USER_ID = user_id_admin; let row_array = [[ADMIN_USER_ID, "admin@123.com", "admin@123.com", "admin@123.com", true, true, "test_admin_1"]]; diff --git a/002_source/pocketbase/pb_hooks/seed/060_Notifications.js b/002_source/pocketbase/pb_hooks/seed/060_Notifications.js index 4bf733d..592f890 100644 --- a/002_source/pocketbase/pb_hooks/seed/060_Notifications.js +++ b/002_source/pocketbase/pb_hooks/seed/060_Notifications.js @@ -5,7 +5,7 @@ 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 } = config; + 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"; @@ -16,10 +16,10 @@ module.exports = ($app) => { // generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs` const SAMPLE_CUSTOMER_ARRAY = [ - [getId("1"), "EV-004", false, "new_job", { id: getId("1"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { title: "Remote React / React Native Developer" }, ""], - [getId("2"), "EV-003", true, "new_job", { id: getId("2"), name: "Fran Perez", avatar: "/assets/avatar-5.png" }, { title: "Senior Golang Backend Engineer" }, ""], - [getId("3"), "EV-002", true, "new_feature", "", "", "Logistics management is now available"], - [getId("4"), "EV-001", true, "new_company", { id: getId("3"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { name: "Stripe" }, ""], + [getId("1"), "EV-004", false, "new_job", { id: getId("1"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { title: "Remote React / React Native Developer" }, "", user_id_admin, user_id_test_teacher_1], + [getId("2"), "EV-003", true, "new_job", { id: getId("2"), name: "Fran Perez", avatar: "/assets/avatar-5.png" }, { title: "Senior Golang Backend Engineer" }, "", user_id_admin, user_id_test_teacher_1], + [getId("3"), "EV-002", true, "new_feature", "", "", "Logistics management is now available", user_id_admin, user_id_test_teacher_1], + [getId("4"), "EV-001", true, "new_company", { id: getId("3"), name: "Jie Yan", avatar: "/assets/avatar-8.png" }, { name: "Stripe" }, "", user_id_admin, user_id_test_teacher_1], ]; let row_array = SAMPLE_CUSTOMER_ARRAY; @@ -35,9 +35,12 @@ module.exports = ($app) => { record.set("NOTI_ID", customer[1]); record.set("read", customer[2]); record.set("type", customer[3]); - record.set("author", customer[4]); + // record.set("author1", customer[4]); record.set("job", customer[5]); record.set("description", customer[6]); + record.set("to_user_id", customer[7]); + record.set("from_user_id", customer[8]); + record.set("author", customer[8]); $app.save(record); } diff --git a/002_source/pocketbase/pb_hooks/seed/config.js b/002_source/pocketbase/pb_hooks/seed/config.js index 891018c..68d01ce 100644 --- a/002_source/pocketbase/pb_hooks/seed/config.js +++ b/002_source/pocketbase/pb_hooks/seed/config.js @@ -24,4 +24,7 @@ module.exports = { CR_cat_id_news: "1".padStart(15, 0), CR_cat_id_sports: "2".padStart(15, 0), CR_cat_id_technology: "3".padStart(15, 0), + // + user_id_admin: "999".padStart(15, 0), + user_id_test_teacher_1: "11".padStart(15, 0), }; diff --git a/002_source/pocketbase/pb_hooks/seed/schema.json b/002_source/pocketbase/pb_hooks/seed/schema.json index d0abb32..f89c32e 100644 --- a/002_source/pocketbase/pb_hooks/seed/schema.json +++ b/002_source/pocketbase/pb_hooks/seed/schema.json @@ -1057,16 +1057,6 @@ "system": false, "type": "text" }, - { - "hidden": false, - "id": "json3182418120", - "maxSize": 0, - "name": "author", - "presentable": false, - "required": false, - "system": false, - "type": "json" - }, { "hidden": false, "id": "json4225294584", @@ -1124,6 +1114,45 @@ "presentable": false, "system": false, "type": "autodate" + }, + { + "cascadeDelete": false, + "collectionId": "pbc_1305841361", + "hidden": false, + "id": "relation704048736", + "maxSelect": 1, + "minSelect": 0, + "name": "to_user_id", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }, + { + "cascadeDelete": false, + "collectionId": "pbc_1305841361", + "hidden": false, + "id": "relation556806202", + "maxSelect": 1, + "minSelect": 0, + "name": "from_user_id", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + }, + { + "cascadeDelete": false, + "collectionId": "pbc_1305841361", + "hidden": false, + "id": "relation3182418120", + "maxSelect": 1, + "minSelect": 0, + "name": "author", + "presentable": false, + "required": false, + "system": false, + "type": "relation" } ], "indexes": [],