"add admin user seed script and refactor common seed utilities"

This commit is contained in:
louiscklaw
2025-05-11 10:34:48 +08:00
parent c29ab4b920
commit 60eed00cb2
26 changed files with 1426 additions and 506 deletions

View File

@@ -1,14 +1,19 @@
module.exports = $app => {
const ASSETS_DIR = '/pb_hooks/assets';
const getAsset = name => $filesystem.fileFromPath(ASSETS_DIR + '/' + name);
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 { getId, getAsset, dirtyTruncateTable } = utils;
// const ASSETS_DIR = "/pb_hooks/assets";
// const getAsset = (name) => $filesystem.fileFromPath(ASSETS_DIR + "/" + name);
for (let i = 0; i < 3; i++) {
let t1_collection = $app.findCollectionByNameOrId('t1');
let t1_collection = $app.findCollectionByNameOrId("t1");
let record = new Record(t1_collection);
record.set('hello', 'world');
let test_png = getAsset('1.png');
record.set('test_file', test_png);
record.set("hello", "world");
let test_png = getAsset("1.png");
record.set("test_file", test_png);
$app.save(record);
}