import { EntityManager } from "typeorm/entity-manager/EntityManager" ; import { CloudStorageConfigsDAO } from "../../../dao" ; import { InsertResult } from "typeorm" ; export class ServiceCloudStorageConfigs { public constructor ( private readonly userUUID ) { } public async createOrUpdate ( totalUsage , t ? ) { return CloudStorageConfigsDAO ( t ) . insert ( { user_uuid : this . userUUID , total_usage : String ( totalUsage ) , } , { orUpdate : { total_usage : String ( totalUsage ) , } , } ) ; } public async totalUsage ( ) { const result = await CloudStorageConfigsDAO ( ) . findOne ( [ "total_usage" ] , { user_uuid : this . userUUID , } ) ; return Number ( result ?. total_usage || 0 ) ; } }