creation thread and comments in socket
This commit is contained in:
59
src/shared/V1Models/Thread/thread-Model.ts
Normal file
59
src/shared/V1Models/Thread/thread-Model.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Document, Schema } from "mongoose";
|
||||
import { User } from "../Auth/userAuthModel.ts";
|
||||
import { Project } from "../Project/project-model.ts";
|
||||
import { Version } from "../Version/versionModel.ts";
|
||||
import MainModel from "../../connect/mongoose.ts";
|
||||
interface IComment {
|
||||
userId: User["_id"];
|
||||
// createdAt: string;
|
||||
comment: string;
|
||||
// lastUpdatedAt: string;
|
||||
timestamp:Number
|
||||
}
|
||||
export interface IThread extends Document {
|
||||
projectId: Project["_id"];
|
||||
versionId: Version["_id"];
|
||||
state: string;
|
||||
commentId: string;
|
||||
createdBy: User["_id"];
|
||||
createdAt: number;
|
||||
lastUpdatedAt: string;
|
||||
position: [number, number, number];
|
||||
rotation: [number, number, number];
|
||||
replies: IComment[];
|
||||
|
||||
}
|
||||
const CommentSchema = new Schema<IComment>(
|
||||
{
|
||||
userId: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||
// createdAt: { type: String, },
|
||||
comment: { type: String,},
|
||||
// lastUpdatedAt: { type: String, },
|
||||
timestamp:{
|
||||
type: Number,
|
||||
default:Date.now()}
|
||||
},
|
||||
// { _id: false } // Prevent automatic _id for each reply object
|
||||
);
|
||||
const threadSchema = new Schema<IThread>({
|
||||
projectId: { type: Schema.Types.ObjectId, ref: 'Project', required: true },
|
||||
state: { type: String, enum: ['active', 'inactive'], required: true },
|
||||
commentId: { type: String, },
|
||||
createdBy: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||
createdAt: { type: Number,},
|
||||
lastUpdatedAt: { type: String, },
|
||||
position: {
|
||||
type: [Number],
|
||||
required: true,
|
||||
},
|
||||
rotation: {
|
||||
type: [Number],
|
||||
required: true,
|
||||
},
|
||||
replies: { type: [CommentSchema ], default: [] },
|
||||
});
|
||||
|
||||
const ThreadModel = (db: string) => {
|
||||
return MainModel(db, "Threads", threadSchema, "Threads");
|
||||
};
|
||||
export default ThreadModel;
|
||||
Reference in New Issue
Block a user