feat: link and unlink document to resource model

This commit is contained in:
Ahmed Bouhuolia
2024-05-24 19:50:06 +02:00
parent c8f31f33be
commit 8f904fae3a
14 changed files with 347 additions and 20 deletions

View File

@@ -1,10 +1,18 @@
import { Service } from 'typedi';
import { S3Client, PutObjectCommand } from '@aws-sdk/client-s3';
import { Inject, Service } from 'typedi';
import HasTenancyService from '../Tenancy/TenancyService';
@Service()
export class UploadDocument {
@Inject()
private tenancy: HasTenancyService;
async upload(tenantId: number, file: any) {
const { Document } = this.tenancy.models(tenantId);
const insertedDocument = await Document.query().insert({
key: file.key,
extension: file.mimetype,
});
return insertedDocument;
}
}