Created
September 15, 2024 13:08
-
-
Save GoodnessEzeokafor/4797116f108e9bdd9ffcc61eebc26008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, OnApplicationShutdown } from '@nestjs/common'; | |
import { FeedbackFactoryServices } from './feedback-factory.service'; | |
import { DataSource } from 'typeorm'; | |
import { IDatabaseServices } from 'src/core'; | |
@Injectable() | |
export class FeedbackServices implements OnApplicationShutdown { | |
constructor( | |
private readonly data: IDatabaseServices, | |
private readonly factory: FeedbackFactoryServices, | |
private readonly connection: DataSource, | |
) {} | |
async onApplicationShutdown(signal: string) { | |
console.log('signal', signal); | |
this.connection.destroy(); | |
} | |
async sendFeedback(payload: any) { | |
const factory = this.factory.create(payload); | |
return await this.data.feedbacks.create(factory); | |
} | |
async getFeedbacks() { | |
return await this.data.feedbacks.findAllWithPagination({}); | |
} | |
async getSingleFeedback() { | |
return await this.data.feedbacks.findOne({ email: '[email protected]' }); | |
} | |
async deleteFeedback() { | |
return await this.data.feedbacks.delete({ email: '[email protected]' }); | |
} | |
async updateFeedback() { | |
return await this.data.feedbacks.update( | |
{ email: '[email protected]' }, | |
{ email: '[email protected]' }, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment