Spaces:
Running
Running
Update models/Project.ts
Browse files- models/Project.ts +39 -4
models/Project.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
| 1 |
-
import mongoose from
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
space_id: {
|
| 5 |
type: String,
|
| 6 |
required: true,
|
|
@@ -13,6 +31,22 @@ const ProjectSchema = new mongoose.Schema({
|
|
| 13 |
type: [String],
|
| 14 |
default: [],
|
| 15 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
_createdAt: {
|
| 17 |
type: Date,
|
| 18 |
default: Date.now,
|
|
@@ -23,5 +57,6 @@ const ProjectSchema = new mongoose.Schema({
|
|
| 23 |
},
|
| 24 |
});
|
| 25 |
|
| 26 |
-
export default mongoose.models.Project ||
|
| 27 |
-
mongoose.model("Project", ProjectSchema);
|
|
|
|
|
|
| 1 |
+
import mongoose, { Schema, Document, models } from 'mongoose';
|
| 2 |
|
| 3 |
+
// Interface for a single page (good practice for TypeScript)
|
| 4 |
+
export interface IPage {
|
| 5 |
+
path: string;
|
| 6 |
+
html: string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
// Update the main Project interface to include new fields
|
| 10 |
+
export interface IProject extends Document {
|
| 11 |
+
user_id: string;
|
| 12 |
+
space_id: string;
|
| 13 |
+
prompts: string[];
|
| 14 |
+
pages?: IPage[]; // 'pages' is now an optional array of IPage
|
| 15 |
+
images?: string[]; // 'images' is now an optional array of strings
|
| 16 |
+
metadata?: object;
|
| 17 |
+
_createdAt: Date;
|
| 18 |
+
_updatedAt: Date;
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
const ProjectSchema: Schema<IProject> = new mongoose.Schema({
|
| 22 |
space_id: {
|
| 23 |
type: String,
|
| 24 |
required: true,
|
|
|
|
| 31 |
type: [String],
|
| 32 |
default: [],
|
| 33 |
},
|
| 34 |
+
// Add 'pages' to the schema
|
| 35 |
+
pages: {
|
| 36 |
+
type: [{
|
| 37 |
+
path: { type: String, required: true },
|
| 38 |
+
html: { type: String, required: true },
|
| 39 |
+
}],
|
| 40 |
+
default: [],
|
| 41 |
+
},
|
| 42 |
+
// Add 'images' to the schema
|
| 43 |
+
images: {
|
| 44 |
+
type: [String],
|
| 45 |
+
default: [],
|
| 46 |
+
},
|
| 47 |
+
metadata: {
|
| 48 |
+
type: Object,
|
| 49 |
+
},
|
| 50 |
_createdAt: {
|
| 51 |
type: Date,
|
| 52 |
default: Date.now,
|
|
|
|
| 57 |
},
|
| 58 |
});
|
| 59 |
|
| 60 |
+
export default mongoose.models.Project as mongoose.Model<IProject> ||
|
| 61 |
+
mongoose.model<IProject>("Project", ProjectSchema);
|
| 62 |
+
|