
add billing address seed data and update user seed scripts with teacher and student roles ```
78 lines
3.0 KiB
JavaScript
78 lines
3.0 KiB
JavaScript
//
|
|
// RULES:
|
|
// this is not a normal nodejs engine,
|
|
// it is a nodejs provided by golang,
|
|
// so fakerjs cannot be used here
|
|
// use vscode extensions 'Gruntfuggly.align-mode' to align comma
|
|
//
|
|
const config = require("/pb_hooks/seed/config.js");
|
|
const utils = require("/pb_hooks/seed/utils.js");
|
|
|
|
module.exports = ($app) => {
|
|
const { CR_cat_id_news, CR_cat_id_technology } = config;
|
|
const { getId, getAsset, randomId } = utils;
|
|
|
|
let row_array = [
|
|
[getId("1"), "[email protected]", "[email protected]", "[email protected]", true, true, "test_student_1"],
|
|
[getId("2"), "[email protected]", "[email protected]", "[email protected]", true, true, "test_student_2"],
|
|
[getId("3"), "[email protected]", "[email protected]", "[email protected]", true, true, "test_student_3"],
|
|
[getId("4"), "[email protected]", "[email protected]", "[email protected]", true, true, "test_student_4"],
|
|
[getId("5"), "[email protected]", "[email protected]", "[email protected]", true, true, "test_student_5"],
|
|
];
|
|
|
|
// um = user_meta
|
|
let um_row_array = [
|
|
[getId("1"), "[email protected]", "active", getId("1"), JSON.stringify({}), getAsset("people1.png"), "student", "student_1"],
|
|
[getId("2"), "[email protected]", "pending", getId("2"), JSON.stringify({}), getAsset("people2.png"), "student", "student_2"],
|
|
[getId("3"), "[email protected]", "blocked", getId("3"), JSON.stringify({}), getAsset("people3.png"), "student", "student_3"],
|
|
[getId("4"), "[email protected]", "active", getId("4"), JSON.stringify({}), getAsset("people4.png"), "student", "student_4"],
|
|
[getId("5"), "[email protected]", "pending", getId("5"), JSON.stringify({}), getAsset("people5.png"), "student", "student_5"],
|
|
];
|
|
|
|
let users_collection = $app.findCollectionByNameOrId("users");
|
|
let user_metas_collection = $app.findCollectionByNameOrId("UserMetas");
|
|
|
|
for (let i = 0; i < 1; 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("status", um[2]);
|
|
um_record.set("user_id", um[3]);
|
|
um_record.set("meta", um[4]);
|
|
|
|
// NOTE: obslete "avatar" and use "avatar_file"
|
|
um_record.set("avatar", um[5]);
|
|
um_record.set("avatar_file", um[5]);
|
|
//
|
|
|
|
um_record.set("name", um[7]);
|
|
um_record.set("email", user[3]);
|
|
um_record.set("phone", "9123456" + i.toString());
|
|
um_record.set("company", "company_" + i.toString());
|
|
um_record.set("taxId", "taxId_" + i.toString());
|
|
um_record.set("timezone", "America/New_York");
|
|
um_record.set("language", "en");
|
|
um_record.set("currency", "EUR");
|
|
um_record.set("billingAddress", randomId(10));
|
|
|
|
um_record.set("role", um[6]);
|
|
|
|
$app.save(um_record);
|
|
}
|
|
|
|
console.log("064 add student user done");
|
|
};
|