update notifications,
This commit is contained in:
152
002_source/pocketbase/pb_hooks/seed/051_Teachers.js
Normal file
152
002_source/pocketbase/pb_hooks/seed/051_Teachers.js
Normal file
@@ -0,0 +1,152 @@
|
||||
//
|
||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||
//
|
||||
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
|
||||
const getId = (id) => id.padStart(15, 0);
|
||||
|
||||
// generate from `./project/001_documentation/Requirements/REQ0006/gen_customer/gen_customer.mjs`
|
||||
const TEACHER_ARRAY = [
|
||||
[
|
||||
getId("1"),
|
||||
"May",
|
||||
getAsset("teacher1.png"),
|
||||
"June_Wintheiser33@hotmail.com",
|
||||
"281-378-5900 x822",
|
||||
"Green, Rempel and Hoeger",
|
||||
{
|
||||
country: "UK",
|
||||
state: "Arizona",
|
||||
city: "Winfieldburgh",
|
||||
zipCode: "92017-8004",
|
||||
line1: "1838 Willa Freeway",
|
||||
line2: "Suite 307",
|
||||
},
|
||||
98,
|
||||
"Asia/Urumqi",
|
||||
"fr",
|
||||
"USD",
|
||||
"active",
|
||||
],
|
||||
[
|
||||
getId("2"),
|
||||
"Marilyne",
|
||||
getAsset("teacher2.png"),
|
||||
"Carol_Blick@yahoo.com",
|
||||
"(893) 919-2445 x193",
|
||||
"White - Hessel",
|
||||
{
|
||||
country: "US",
|
||||
state: "Nevada",
|
||||
city: "Casa Grande",
|
||||
zipCode: "83831-3843",
|
||||
line1: "6984 Alberto Radial",
|
||||
line2: "Suite 154",
|
||||
},
|
||||
49,
|
||||
"Africa/Tunis",
|
||||
"es",
|
||||
"EUR",
|
||||
"pending",
|
||||
],
|
||||
[
|
||||
getId("3"),
|
||||
"Jacklyn",
|
||||
getAsset("teacher3.png"),
|
||||
"Tamara_Lynch11@yahoo.com",
|
||||
"597-593-0144 x168",
|
||||
"Rolfson LLC",
|
||||
{
|
||||
country: "CA",
|
||||
state: "Georgia",
|
||||
city: "New Brodyfort",
|
||||
zipCode: "18887-7075",
|
||||
line1: "493 Pfannerstill Meadow",
|
||||
line2: "Apt. 358",
|
||||
},
|
||||
44,
|
||||
"Asia/Manila",
|
||||
"en",
|
||||
"GBP",
|
||||
"blocked",
|
||||
],
|
||||
[
|
||||
getId("4"),
|
||||
"Alana",
|
||||
getAsset("teacher4.png"),
|
||||
"Ahmed_Willms@hotmail.com",
|
||||
"401.212.0386 x31125",
|
||||
"Friesen, Langworth and Thompson",
|
||||
{
|
||||
country: "UK",
|
||||
state: "North Carolina",
|
||||
city: "Fort Jerrell",
|
||||
zipCode: "14211",
|
||||
line1: "1763 West Street",
|
||||
line2: "Suite 699",
|
||||
},
|
||||
34,
|
||||
"America/Boa_Vista",
|
||||
"es",
|
||||
"USD",
|
||||
"active",
|
||||
],
|
||||
[
|
||||
getId("5"),
|
||||
"Rocky",
|
||||
getAsset("teacher5.png"),
|
||||
"Angela_Kuhic@gmail.com",
|
||||
"653.964.0412",
|
||||
"Hayes - Morar",
|
||||
{
|
||||
country: "US",
|
||||
state: "New York",
|
||||
city: "Kayton",
|
||||
zipCode: "82048-0645",
|
||||
line1: "636 Angel Junction",
|
||||
line2: "Apt. 361",
|
||||
},
|
||||
70,
|
||||
"America/Grand_Turk",
|
||||
"fr",
|
||||
"EUR",
|
||||
"pending",
|
||||
],
|
||||
];
|
||||
|
||||
let row_array = TEACHER_ARRAY;
|
||||
dirtyTruncateTable("Teachers");
|
||||
|
||||
let lt_collection = $app.findCollectionByNameOrId("Teachers");
|
||||
|
||||
for (let i = 0; i < row_array.length; i++) {
|
||||
let teacher = row_array[i];
|
||||
|
||||
let record = new Record(lt_collection);
|
||||
record.set("id", teacher[0]);
|
||||
record.set("name", teacher[1]);
|
||||
record.set("avatar_file", teacher[2]);
|
||||
record.set("email", teacher[3]);
|
||||
record.set("phone", teacher[4]);
|
||||
record.set("company", teacher[5]);
|
||||
record.set("billingAddress", teacher[6]);
|
||||
record.set("taxId", teacher[7]);
|
||||
record.set("timezone", teacher[8]);
|
||||
record.set("language", teacher[9]);
|
||||
record.set("currency", teacher[10]);
|
||||
record.set("status", teacher[11]);
|
||||
|
||||
$app.save(record);
|
||||
}
|
||||
|
||||
console.log(`051_Teacher 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();
|
||||
};
|
Reference in New Issue
Block a user