diff --git a/controller/media.ts b/controller/media.ts index 6401f2a..d14de7d 100644 --- a/controller/media.ts +++ b/controller/media.ts @@ -1,4 +1,4 @@ -import {Media} from "../models/Media"; +import {IMedia, Media} from "../models/Media"; import {Response} from "express"; import {bucket} from "./bucket"; @@ -15,13 +15,13 @@ export const createMedia = (clientId: number, assetName: string, assetEnding: st * Gets a media object from an id * @param assetId The id of the asset to search */ -export const getMediaById = (assetId: string) => Media.findOne({assetId}, {_id: 0, __v: 0}); +export const getMediaById = (assetId: string) => Media.findOne({where: {assetId}}); /** * Gets a complete media object by the asset id * @param assetId The id of the asset to search */ -export const getMediaObject = (assetId: string) => Media.findOne({assetId}); +export const getMediaObject = (assetId: string) => Media.findOne({where: {assetId}}) as Promise; /** * Pipes the provided asset into an express response @@ -35,6 +35,6 @@ export const pipeMedia = (assetId: string, res: Response) => bucket.file(assetId * @param assetId The id of the asset to delete */ export const deleteMedia = async (assetId: string) => { - await Media.deleteOne({assetId}); + await Media.destroy({where: {assetId}}); await bucket.file(assetId).delete(); } \ No newline at end of file