feat: flatten file tree for better performance

This commit is contained in:
tdurieux
2024-04-26 10:31:57 +01:00
parent ccdc95e4a8
commit 710f7328e7
23 changed files with 516 additions and 514 deletions
+8
View File
@@ -0,0 +1,8 @@
import { model } from "mongoose";
import { join } from "path";
import { IFileDocument, IFileModel } from "./files.types";
import FileSchema from "./files.schema";
const FileModel = model<IFileDocument>("File", FileSchema) as IFileModel;
export default FileModel;
+19
View File
@@ -0,0 +1,19 @@
import { Schema } from "mongoose";
const FileSchema = new Schema({
name: { type: String, index: true },
path: { type: String, index: true },
repoId: { type: String, index: true },
sha: {
type: String,
},
size: {
type: Number,
},
});
FileSchema.methods.toString = function () {
return `${this.path}/${this.name}`;
};
export default FileSchema;
+14
View File
@@ -0,0 +1,14 @@
import { Document, Model } from "mongoose";
export interface IFile {
name: string;
path: string;
repoId: string;
sha?: string;
size?: number;
}
export interface IFileDocument extends IFile, Document {
toString: (this: IFileDocument) => string;
}
export interface IFileModel extends Model<IFileDocument> {}