49 lines
2.5 KiB
JavaScript
49 lines
2.5 KiB
JavaScript
const config = require("/pb_hooks/seed/config.js");
|
|
const utils = require("/pb_hooks/seed/utils.js");
|
|
|
|
module.exports = ($app) => {
|
|
const { LP_cat_id_news, LP_cat_id_sports, LP_cat_id_technology } = config;
|
|
const { getId, getAsset, dirtyTruncateTable } = utils;
|
|
|
|
let row_array = [
|
|
[getId("1"), "news (LP)", getAsset("ci_news.jpg"), 1, ["A", "B", "C"], "visible", "news", getAsset("keyboard.mp3"), LP_cat_id_news],
|
|
[getId("2"), "sports (LP)", getAsset("ci_sports.jpg"), 2, ["A", "B", "C"], "visible", "sports", getAsset("mouse.mp3"), LP_cat_id_news],
|
|
[getId("3"), "technology (LP)", getAsset("ci_technology.jpg"), 3, ["A", "B", "C"], "visible", "technology", getAsset("keyboard.mp3"), LP_cat_id_news],
|
|
[getId("4"), "art (LP)", getAsset("ci_art.jpg"), 4, ["A", "B", "C"], "visible", "art", getAsset("mouse.mp3"), LP_cat_id_sports],
|
|
[getId("5"), "basic (LP)", getAsset("ci_basic.jpg"), 5, ["A", "B", "C"], "visible", "basic", getAsset("keyboard.mp3"), LP_cat_id_sports],
|
|
[getId("6"), "nature (LP)", getAsset("ci_nature.jpg"), 6, ["A", "B", "C"], "visible", "nature", getAsset("keyboard.mp3"), LP_cat_id_sports],
|
|
[getId("7"), "workplace (LP)", getAsset("ci_workplace.jpg"), 7, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
|
[getId("8"), "workplace (LP)", getAsset("ci_workplace.jpg"), 8, ["A", "B", "C"], "visible", "workplace", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
|
[getId("99"), "test hidden (LP)", getAsset("ci_workplace.jpg"), 9, ["A", "B", "C"], "hidden", "test", getAsset("keyboard.mp3"), LP_cat_id_technology],
|
|
];
|
|
dirtyTruncateTable("QuizLPQuestions");
|
|
|
|
let lt_collection = $app.findCollectionByNameOrId("QuizLPQuestions");
|
|
|
|
for (let i = 0; i < row_array.length; i++) {
|
|
let lesson_type = row_array[i];
|
|
|
|
let record = new Record(lt_collection);
|
|
record.set("id", lesson_type[0]);
|
|
record.set("cat_name", lesson_type[1]);
|
|
record.set("cat_image", lesson_type[2]);
|
|
record.set("pos", lesson_type[3]);
|
|
record.set("init_answer", lesson_type[4]);
|
|
record.set("visible", lesson_type[5]);
|
|
record.set("word", lesson_type[6]);
|
|
record.set("sound", lesson_type[7]);
|
|
record.set("cat_id", lesson_type[8]);
|
|
|
|
$app.save(record);
|
|
}
|
|
|
|
console.log(`021_QuizLPQuestions done`);
|
|
};
|
|
|
|
// 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();
|
|
// };
|