"add admin user seed script and refactor common seed utilities"
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
//
|
||||
// RULES: this is not a normal nodejs engine, it is a nodejs provided by golang, so fakerjs cannot be used here
|
||||
//
|
||||
const config = require("/pb_hooks/seed/config.js");
|
||||
const utils = require("/pb_hooks/seed/utils.js");
|
||||
//
|
||||
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);
|
||||
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);
|
||||
// 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 SAMPLE_CUSTOMER_ARRAY = [
|
||||
[
|
||||
"000000000000001",
|
||||
getId("1"),
|
||||
"May",
|
||||
getAsset("customer1.png"),
|
||||
"June_Wintheiser33@hotmail.com",
|
||||
@@ -32,7 +38,7 @@ module.exports = ($app) => {
|
||||
"active",
|
||||
],
|
||||
[
|
||||
"000000000000002",
|
||||
getId("2"),
|
||||
"Marilyne",
|
||||
getAsset("customer2.png"),
|
||||
"Carol_Blick@yahoo.com",
|
||||
@@ -53,7 +59,7 @@ module.exports = ($app) => {
|
||||
"pending",
|
||||
],
|
||||
[
|
||||
"000000000000003",
|
||||
getId("3"),
|
||||
"Jacklyn",
|
||||
getAsset("customer3.png"),
|
||||
"Tamara_Lynch11@yahoo.com",
|
||||
@@ -74,7 +80,7 @@ module.exports = ($app) => {
|
||||
"blocked",
|
||||
],
|
||||
[
|
||||
"000000000000004",
|
||||
getId("4"),
|
||||
"Alana",
|
||||
getAsset("customer4.png"),
|
||||
"Ahmed_Willms@hotmail.com",
|
||||
@@ -95,7 +101,7 @@ module.exports = ($app) => {
|
||||
"active",
|
||||
],
|
||||
[
|
||||
"000000000000005",
|
||||
getId("5"),
|
||||
"Rocky",
|
||||
getAsset("customer5.png"),
|
||||
"Angela_Kuhic@gmail.com",
|
||||
@@ -145,8 +151,9 @@ module.exports = ($app) => {
|
||||
console.log(`050_Customers 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();
|
||||
};
|
||||
// TODO: remove me
|
||||
// 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