2022-10-26 19:55:08 +03:00
|
|
|
const TableImporter = require('./base');
|
|
|
|
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 {
|
|
|
|
constructor(knex) {
|
|
|
|
super('users', knex);
|
|
|
|
}
|
|
|
|
|
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 {
|
|
|
|
id: faker.database.mongodbObjectId(),
|
|
|
|
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;
|