Files
lettersoup-online/002_source/pocketbase/pb_hooks/seed/utils.js
louiscklaw 3e1f2e1057 ```
add billing address seed data and update user seed scripts with teacher and student roles
```
2025-05-13 12:35:05 +08:00

24 lines
735 B
JavaScript

const config = require("/pb_hooks/seed/config.js");
module.exports = {
getAsset: (name) => {
const file_full_path = config.ASSETS_DIR + "/" + name;
try {
return $filesystem.fileFromPath(file_full_path);
} catch (error) {
console.log("file not found: " + file_full_path, +"please check if file exist");
}
},
getId: (id) => id.padStart(15, 0),
randomId: (max) =>
Math.floor(Math.random() * max)
.toString()
.padStart(15, 0),
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();
},
};