Spaces:
Running
Running
File size: 1,337 Bytes
7f6c5d9 13ae717 7f6c5d9 13ae717 7f6c5d9 13ae717 7f6c5d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
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);
|