Skip to content

Commit

Permalink
Merge pull request #443 from Sid-80/feat/schemas
Browse files Browse the repository at this point in the history
feat: scheams
  • Loading branch information
subhadeeproy3902 authored Jul 9, 2024
2 parents d453124 + 0ffd318 commit ce9d052
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/models/file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import mongoose, { Schema } from "mongoose";

interface File {
fileName: string;
createdBy: any;
archive: boolean;
document: string;
whiteboard: string;
private: boolean;
writtenBy: any[];
readBy: any[];
write: boolean;
read: boolean;
}

const FileSchema = new Schema<File>(
{
fileName: { type: String, required: true },
createdBy: { type: Schema.Types.ObjectId, required: true, ref: "User" },
archive: { type: Boolean },
document: { type: String },
whiteboard: { type: String },
private: { type: Boolean, required: true },
writtenBy: [{ type: Schema.Types.ObjectId, required: true, ref: "User" }],
readBy: [{ type: Schema.Types.ObjectId, required: true, ref: "User" }],
write: { type: Boolean },
read: { type: Boolean },
},
{ timestamps: true }
);

const FileModel =
mongoose.models?.File || mongoose.model<File>("File", FileSchema);

export default FileModel;
21 changes: 21 additions & 0 deletions src/models/team.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import mongoose, { Schema } from "mongoose";

interface Team {
teamName: string;
createdBy: any;
teamMembers: any[];
}

const TeamSchema = new Schema<Team>(
{
teamName: { type: String, required: true },
createdBy: { type: Schema.Types.ObjectId, required: true, ref: "User" },
teamMembers: [{ type: Schema.Types.ObjectId, required: true, ref: "User" }],
},
{ timestamps: true }
);

const TeamModel =
mongoose.models?.Team || mongoose.model<Team>("Team", TeamSchema);

export default TeamModel;

0 comments on commit ce9d052

Please sign in to comment.