update pocketbase,

This commit is contained in:
louiscklaw
2025-04-19 02:12:02 +08:00
parent 60a0cdc11d
commit 85ee8d848d
63 changed files with 196 additions and 22654 deletions

2
002_source/pocketbase/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
#
volumes

View File

@@ -15,6 +15,7 @@ $app.rootCmd.addCommand(
require(`${__hooks}/seed/001_seed_LessonsTypes.js`)($app);
require(`${__hooks}/seed/002_LessonsCategories.js`)($app);
require(`${__hooks}/seed/003_Categories.js`)($app);
require(`${__hooks}/seed/004_Users.js`)($app);
require(`${__hooks}/seed/010_Vocabularies.js`)($app);
$app.reloadCachedCollections();

View File

@@ -5,94 +5,15 @@ module.exports = ($app) => {
const id_c = "2".padStart(15, 0); //id_connectives
let row_array = [
[
"1".padStart(15, 0),
"news",
"",
getAsset("ci_news.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"2".padStart(15, 0),
"sports",
"",
getAsset("ci_sports.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"3".padStart(15, 0),
"technology",
"",
getAsset("ci_technology.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"4".padStart(15, 0),
"art",
"",
getAsset("ci_art.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"5".padStart(15, 0),
"basic",
"",
getAsset("ci_basic.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"6".padStart(15, 0),
"nature",
"",
getAsset("ci_nature.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"7".padStart(15, 0),
"workplace",
"",
getAsset("ci_workplace.jpg"),
1,
"visible",
id_v,
"desc",
"remarks",
],
[
"99".padStart(15, 0),
"connectives",
"",
getAsset("1.png"),
1,
"visible",
id_c,
"desc",
"remarks",
],
["1".padStart(15, 0), "news", "", getAsset("ci_news.jpg"), 1, "visible", id_v, "desc", "remarks"],
["2".padStart(15, 0), "sports", "", getAsset("ci_sports.jpg"), 1, "visible", id_v, "desc", "remarks"],
["3".padStart(15, 0), "technology", "", getAsset("ci_technology.jpg"), 1, "visible", id_v, "desc", "remarks"],
["4".padStart(15, 0), "art", "", getAsset("ci_art.jpg"), 1, "visible", id_v, "desc", "remarks"],
["5".padStart(15, 0), "basic", "", getAsset("ci_basic.jpg"), 1, "visible", id_v, "desc", "remarks"],
["6".padStart(15, 0), "nature", "", getAsset("ci_nature.jpg"), 1, "visible", id_v, "desc", "remarks"],
["7".padStart(15, 0), "workplace", "", getAsset("ci_workplace.jpg"), 1, "visible", id_v, "desc", "remarks"],
["8".padStart(15, 0), "workplace", "", getAsset("ci_workplace.jpg"), 1, "hidden", id_v, "desc", "remarks"],
["99".padStart(15, 0), "connectives", "", getAsset("1.png"), 1, "visible", id_c, "desc", "remarks"],
// ["2".padStart(15, 0), "Connectives", "connectivse", 1, "visible"],
// ["3".padStart(15, 0), "Testing visible", "testing", 3, "visible"],
// ["4".padStart(15, 0), "Testing hidden", "testing", 3, "hidden"],
@@ -123,10 +44,6 @@ module.exports = ($app) => {
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};`
);
const cmd_to_exec = $os.cmd("sqlite3", "/pb_data/data.db", `DELETE from ${COLLECTION_NAME};`);
cmd_to_exec.output();
};

View File

@@ -0,0 +1,58 @@
module.exports = ($app) => {
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
let row_array = [
["1".padStart(15, 0), "user1@123.com", "user1@123.com", "user1@123.com", true, true, "test_user_1"],
["2".padStart(15, 0), "user2@123.com", "user2@123.com", "user2@123.com", true, true, "test_user_2"],
["3".padStart(15, 0), "user3@123.com", "user3@123.com", "user3@123.com", true, true, "test_user_3"],
["4".padStart(15, 0), "user4@123.com", "user4@123.com", "user4@123.com", true, true, "test_user_4"],
["5".padStart(15, 0), "user5@123.com", "user5@123.com", "user5@123.com", true, true, "test_user_5"],
];
dirtyTruncateTable("Users");
let um_row_array = [
["1".padStart(15, 0), "user1@123.com", "active", "1".padStart(15, 0), JSON.stringify({})],
["2".padStart(15, 0), "user2@123.com", "active", "2".padStart(15, 0), JSON.stringify({})],
["3".padStart(15, 0), "user3@123.com", "active", "3".padStart(15, 0), JSON.stringify({})],
["4".padStart(15, 0), "user4@123.com", "active", "4".padStart(15, 0), JSON.stringify({})],
["5".padStart(15, 0), "user5@123.com", "active", "5".padStart(15, 0), JSON.stringify({})],
];
dirtyTruncateTable("UserMetas");
let users_collection = $app.findCollectionByNameOrId("users");
let user_metas_collection = $app.findCollectionByNameOrId("UserMetas");
for (let i = 0; i < row_array.length; i++) {
let user = row_array[i];
let um = um_row_array[i];
let record = new Record(users_collection);
record.set("id", user[0]);
record.set("password", user[1]);
record.set("passwordConfirm", user[2]);
record.set("email", user[3]);
record.set("emailVisibility", user[4]);
record.set("verified", user[5]);
record.set("name", user[6]);
$app.save(record);
let um_record = new Record(user_metas_collection);
um_record.set("id", um[0]);
um_record.set("helloworld", um[1]);
um_record.set("state", um[2]);
um_record.set("user_id", um[3]);
um_record.set("meta", um[4]);
$app.save(um_record);
}
console.log("seeding done");
};
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();
};

View File

@@ -0,0 +1,42 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update field
collection.fields.addAt(1, new Field({
"autogeneratePattern": "",
"hidden": false,
"id": "text4192936109",
"max": 0,
"min": 0,
"name": "address",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update field
collection.fields.addAt(1, new Field({
"autogeneratePattern": "",
"hidden": false,
"id": "text4192936109",
"max": 0,
"min": 0,
"name": "helloworld",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}))
return app.save(collection)
})

View File

@@ -0,0 +1,29 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// add field
collection.fields.addAt(4, new Field({
"autogeneratePattern": "",
"hidden": false,
"id": "text2744374011",
"max": 0,
"min": 0,
"name": "state",
"pattern": "",
"presentable": false,
"primaryKey": false,
"required": false,
"system": false,
"type": "text"
}))
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// remove field
collection.fields.removeById("text2744374011")
return app.save(collection)
})

View File

@@ -0,0 +1,26 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update collection data
unmarshal({
"createRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update collection data
unmarshal({
"createRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

View File

@@ -0,0 +1,28 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update collection data
unmarshal({
"createRule": "",
"deleteRule": "",
"listRule": "",
"updateRule": "",
"viewRule": ""
}, collection)
return app.save(collection)
}, (app) => {
const collection = app.findCollectionByNameOrId("pbc_1305841361")
// update collection data
unmarshal({
"createRule": null,
"deleteRule": null,
"listRule": null,
"updateRule": null,
"viewRule": null
}, collection)
return app.save(collection)
})

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_art.jpg"},"md5":"hX9DjNrDpizkfpovi+cydQ=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_basic.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_nature.jpg"},"md5":"hhmnaiHqT5YtnutDywypjQ=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_workplace.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"1.png"},"md5":"x4R9FNKJvUD7IZ6bfx2jBw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_news.jpg"},"md5":"J1tuB8xBbhmsejfumKyMCw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_sports.jpg"},"md5":"XHkiO4OuiuEKOfFdbK/krA=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_technology.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_art.jpg"},"md5":"hX9DjNrDpizkfpovi+cydQ=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_basic.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_nature.jpg"},"md5":"hhmnaiHqT5YtnutDywypjQ=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"ci_workplace.jpg"},"md5":"UvMT6MP7AGP05QkffX5yIg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"1.png"},"md5":"x4R9FNKJvUD7IZ6bfx2jBw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"keyboard.jpg"},"md5":"U+pCpPJoC0V042bOt0mX1g=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"audio/mpeg","user.metadata":{"original-filename":"keyboard.mp3"},"md5":"b6Y171U2b4qdK7lnUfOM1g=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/jpeg","user.metadata":{"original-filename":"mouse.jpg"},"md5":"gFkDkSP8hoJVLpJzlyK8Rg=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"audio/mpeg","user.metadata":{"original-filename":"mouse.mp3"},"md5":"v+KXNwrTm8L0p/A9P7IHMQ=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"1.png"},"md5":"x4R9FNKJvUD7IZ6bfx2jBw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"1.png"},"md5":"x4R9FNKJvUD7IZ6bfx2jBw=="}

View File

@@ -1 +0,0 @@
{"user.cache_control":"","user.content_disposition":"","user.content_encoding":"","user.content_language":"","user.content_type":"image/png","user.metadata":{"original-filename":"1.png"},"md5":"x4R9FNKJvUD7IZ6bfx2jBw=="}

File diff suppressed because it is too large Load Diff