From abbba82e6134021f0cb9a2570f32703c8bcb05ef Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 14 Nov 2022 03:01:01 +0000 Subject: [PATCH] Add documentation --- src/models/FileModel.js | 18 +++++++++++------- src/utils/helpers/mongoHelpers.js | 3 +++ src/utils/helpers/webUtils.js | 6 ++++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/models/FileModel.js b/src/models/FileModel.js index 8454dbd..62b0e38 100644 --- a/src/models/FileModel.js +++ b/src/models/FileModel.js @@ -1,13 +1,17 @@ import mongoose, { Schema } from "mongoose"; const schema = new Schema({ - uploader: mongoose.Types.ObjectId, - fileId: String, - originalFileName: String, - uploadDate: Date, - contentType: String, - ext: String, - size: Number, + uploader: mongoose.Types.ObjectId, // The users id who uploaded the file + // The id of the file + fileId: { + type: String, + index: true, + }, + originalFileName: String, // The name of the original file + uploadDate: Date, // The date when the file was uploaded + contentType: String, // The mimetype of the file + ext: String, // The extention of the file + size: Number, // The size of the file // Image/Video specific properties width: Number, // The width of the image/video in pixels diff --git a/src/utils/helpers/mongoHelpers.js b/src/utils/helpers/mongoHelpers.js index ec03782..9dfddd8 100644 --- a/src/utils/helpers/mongoHelpers.js +++ b/src/utils/helpers/mongoHelpers.js @@ -1,5 +1,8 @@ import mongoose from "mongoose"; +/** + * Connect to the database + */ export async function connectMongo() { try { await mongoose.connect(process.env.MONGODB_CONNECTION_STRING); diff --git a/src/utils/helpers/webUtils.js b/src/utils/helpers/webUtils.js index 848c57b..17b7ce8 100644 --- a/src/utils/helpers/webUtils.js +++ b/src/utils/helpers/webUtils.js @@ -1,3 +1,9 @@ +/** + * Downloads a file to the users browser + * + * @param {string} uri The url to the file + * @param {string} name The name of the file to be saved + */ export function downloadURI(uri, name) { var link = document.createElement("a"); link.download = name;