Я работаю с Nest JS и TypeORM. При попытке вызвать метод репозитория createMailLogEntry я получаю следующую ошибку: TypeError: this.mailLogEntryRepository.createMailLogEntry is not a function
Не могу понять, что происходит.
mailing.service .ts
@Injectable()
export class MailingService {
constructor(@InjectRepository(MailLogEntryRepository) private mailLogEntryRepository: MailLogEntryRepository) { }
// ...
if(transferResult) {
await this.mailLogEntryRepository.createMailLogEntry({
creationDate: new Date(Date.now()),
from: mailContent.from,
to: mailContent.to,
subject: mailContent.subject,
text: mailContent.text,
html: mailContent.html,
cc: mailContent.cc,
bcc: mailContent.bcc,
});
}
}
}
mail-log-entry.repository.ts
@EntityRepository(MailLogEntry)
export class MailLogEntryRepository extends Repository<MailLogEntry> {
async createMailLogEntry(mailLogEntryDto: MailLogEntryDto): Promise<MailLogEntry> {
const mailLogEntry = MailLogEntryRepository.createMailLogEntryFromDto(mailLogEntryDto);
return await mailLogEntry.save();
}
private static createMailLogEntryFromDto(mailLogEntryDto: MailLogEntryDto): MailLogEntry {
const mailLogEntry = new MailLogEntry();
mailLogEntry.from = mailLogEntryDto.from;
mailLogEntry.to = mailLogEntryDto.to;
mailLogEntry.subject = mailLogEntryDto.subject;
mailLogEntry.text = mailLogEntryDto.text;
mailLogEntry.html = mailLogEntryDto.html;
mailLogEntry.cc = mailLogEntryDto.cc;
mailLogEntry.bcc = mailLogEntryDto.bcc;
return mailLogEntry;
}
}