-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anmol Sharma <anmolsharma0234@gmail.com>
- Loading branch information
1 parent
713caa5
commit 624137d
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Column, Entity, PrimaryColumn } from 'typeorm'; | ||
|
||
@Entity() | ||
export class OperationState { | ||
@PrimaryColumn('text') | ||
id: string; | ||
|
||
@Column('jsonb') | ||
state: any; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { OperationState } from '@/operation-state/operation-state.entity'; | ||
import { OperationStateService } from '@/operation-state/operation-state.service'; | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([OperationState])], | ||
controllers: [], | ||
providers: [OperationStateService], | ||
exports: [OperationStateService], | ||
}) | ||
export class OperationStateModule {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Repository } from 'typeorm'; | ||
import { OperationState } from '@/operation-state/operation-state.entity'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
|
||
@Injectable() | ||
export class OperationStateService { | ||
constructor( | ||
@InjectRepository(OperationState) | ||
private readonly operationStateRepository: Repository<OperationState>, | ||
) {} | ||
|
||
async getOperationState(id: string): Promise<OperationState> { | ||
return this.operationStateRepository.findOneBy({ id: id }); | ||
} | ||
|
||
async setOperationState(id: string, state: any): Promise<OperationState> { | ||
const operationState = new OperationState(); | ||
operationState.id = id; | ||
operationState.state = state; | ||
return this.operationStateRepository.save(operationState); | ||
} | ||
} |