2023-08-02 16:43:26 +03:00
|
|
|
const TableImporter = require('./TableImporter');
|
2022-10-26 19:55:08 +03:00
|
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
const {slugify} = require('@tryghost/string');
|
|
|
|
const security = require('@tryghost/security');
|
2022-11-03 14:08:03 +03:00
|
|
|
const dateToDatabaseString = require('../utils/database-date');
|
2022-10-26 19:55:08 +03:00
|
|
|
|
|
|
|
class UsersImporter extends TableImporter {
|
2023-02-16 15:11:00 +03:00
|
|
|
static table = 'users';
|
2023-08-02 16:43:26 +03:00
|
|
|
static dependencies = [];
|
|
|
|
defaultQuantity = 8;
|
2023-02-16 15:11:00 +03:00
|
|
|
|
2023-08-02 16:43:26 +03:00
|
|
|
constructor(knex, transaction) {
|
|
|
|
super(UsersImporter.table, knex, transaction);
|
2022-10-26 19:55:08 +03:00
|
|
|
}
|
|
|
|
|
2022-11-03 14:08:03 +03:00
|
|
|
async generate() {
|
2022-10-26 19:55:08 +03:00
|
|
|
const name = `${faker.name.firstName()} ${faker.name.lastName()}`;
|
|
|
|
return {
|
2024-01-05 16:42:30 +03:00
|
|
|
id: this.fastFakeObjectId(),
|
2022-10-26 19:55:08 +03:00
|
|
|
name: name,
|
|
|
|
slug: slugify(name),
|
2022-11-03 14:08:03 +03:00
|
|
|
password: await security.password.hash(faker.color.human()),
|
2022-10-26 19:55:08 +03:00
|
|
|
email: faker.internet.email(name),
|
|
|
|
profile_image: faker.internet.avatar(),
|
2022-11-03 14:08:03 +03:00
|
|
|
created_at: dateToDatabaseString(faker.date.between(new Date(2016, 0), new Date())),
|
2022-10-26 19:55:08 +03:00
|
|
|
created_by: 'unused'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = UsersImporter;
|