add OfficeFolderAnchorsRepository
This commit is contained in:
parent
f961fc6eaa
commit
49e8f1d89b
68
src/common/repositories/OfficeFolderAnchorsRepository.ts
Normal file
68
src/common/repositories/OfficeFolderAnchorsRepository.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import Database from "@Common/databases/database";
|
||||
import BaseRepository from "@Repositories/BaseRepository";
|
||||
import { Service } from "typedi";
|
||||
import { OfficeFolderAnchors, Prisma } from "@prisma/client";
|
||||
import { OfficeFolderAnchor } from "le-coffre-resources/dist/SuperAdmin";
|
||||
|
||||
@Service()
|
||||
export default class OfficeFolderAnchorsRepository extends BaseRepository {
|
||||
constructor(private database: Database) {
|
||||
super();
|
||||
}
|
||||
protected get model() {
|
||||
return this.database.getClient().officeFolderAnchors;
|
||||
}
|
||||
protected get instanceDb() {
|
||||
return this.database.getClient();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Create new office folder anchor
|
||||
*/
|
||||
public async create(officeFolderAnchor: OfficeFolderAnchor): Promise<OfficeFolderAnchors> {
|
||||
const createArgs: Prisma.OfficeFolderAnchorsCreateArgs = {
|
||||
data: {
|
||||
hash_sources: officeFolderAnchor.hash_sources,
|
||||
root_hash: officeFolderAnchor.root_hash!,
|
||||
|
||||
blockchain: officeFolderAnchor.blockchain as OfficeFolderAnchors["blockchain"],
|
||||
status: officeFolderAnchor.status as OfficeFolderAnchors["status"],
|
||||
|
||||
anchor_nb_try: officeFolderAnchor.anchor_nb_try,
|
||||
tx_id: officeFolderAnchor.tx_id,
|
||||
tx_link: officeFolderAnchor.tx_link,
|
||||
tx_hash: officeFolderAnchor.tx_hash,
|
||||
|
||||
anchored_at: officeFolderAnchor.anchored_at,
|
||||
},
|
||||
};
|
||||
|
||||
return this.model.create({ ...createArgs });
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : Update data of an office folder anchor
|
||||
*/
|
||||
public async update(officeFolderAnchorUid: string, officeFolderAnchor: OfficeFolderAnchor): Promise<OfficeFolderAnchors> {
|
||||
const updateArgs: Prisma.OfficeFolderAnchorsUpdateArgs = {
|
||||
where: {
|
||||
uid: officeFolderAnchorUid,
|
||||
},
|
||||
data: {
|
||||
blockchain: officeFolderAnchor.blockchain as OfficeFolderAnchors["blockchain"],
|
||||
status: officeFolderAnchor.status as OfficeFolderAnchors["status"],
|
||||
|
||||
anchor_nb_try: officeFolderAnchor.anchor_nb_try,
|
||||
tx_id: officeFolderAnchor.tx_id,
|
||||
tx_link: officeFolderAnchor.tx_link,
|
||||
tx_hash: officeFolderAnchor.tx_hash,
|
||||
|
||||
anchored_at: officeFolderAnchor.anchored_at,
|
||||
},
|
||||
};
|
||||
|
||||
return this.model.update({
|
||||
...updateArgs,
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user