mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
28 lines
894 B
JavaScript
28 lines
894 B
JavaScript
|
const {faker} = require('@faker-js/faker');
|
||
|
const TableImporter = require('./TableImporter');
|
||
|
|
||
|
class MembersNewslettersImporter extends TableImporter {
|
||
|
static table = 'members_newsletters';
|
||
|
static dependencies = ['members_subscribe_events'];
|
||
|
|
||
|
constructor(knex, transaction) {
|
||
|
super(MembersNewslettersImporter.table, knex, transaction);
|
||
|
}
|
||
|
|
||
|
async import(quantity) {
|
||
|
const membersSubscribeEvents = await this.transaction.select('member_id', 'newsletter_id').from('members_subscribe_events');
|
||
|
|
||
|
await this.importForEach(membersSubscribeEvents, quantity ? quantity / membersSubscribeEvents.length : 1);
|
||
|
}
|
||
|
|
||
|
generate() {
|
||
|
return {
|
||
|
id: faker.database.mongodbObjectId(),
|
||
|
member_id: this.model.member_id,
|
||
|
newsletter_id: this.model.newsletter_id
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = MembersNewslettersImporter;
|