RaBU-2 / models /Project.ts
legends810's picture
Update models/Project.ts
7f6c5d9 verified
import mongoose, { Schema, Document, models } from 'mongoose';
// Interface for a single page (good practice for TypeScript)
export interface IPage {
path: string;
html: string;
}
// Update the main Project interface to include new fields
export interface IProject extends Document {
user_id: string;
space_id: string;
prompts: string[];
pages?: IPage[]; // 'pages' is now an optional array of IPage
images?: string[]; // 'images' is now an optional array of strings
metadata?: object;
_createdAt: Date;
_updatedAt: Date;
}
const ProjectSchema: Schema<IProject> = new mongoose.Schema({
space_id: {
type: String,
required: true,
},
user_id: {
type: String,
required: true,
},
prompts: {
type: [String],
default: [],
},
// Add 'pages' to the schema
pages: {
type: [{
path: { type: String, required: true },
html: { type: String, required: true },
}],
default: [],
},
// Add 'images' to the schema
images: {
type: [String],
default: [],
},
metadata: {
type: Object,
},
_createdAt: {
type: Date,
default: Date.now,
},
_updatedAt: {
type: Date,
default: Date.now,
},
});
export default mongoose.models.Project as mongoose.Model<IProject> ||
mongoose.model<IProject>("Project", ProjectSchema);