Spaces:
Sleeping
Sleeping
| const mongoose = require('mongoose'); | |
| // 提示词 Schema | |
| const promptSchema = new mongoose.Schema( | |
| { | |
| title: { | |
| type: String, | |
| required: [true, '请输入提示词标题'], | |
| trim: true, | |
| }, | |
| content: { | |
| type: String, | |
| required: [true, '请输入提示词内容'], | |
| }, | |
| tags: [String], | |
| createdAt: { | |
| type: Date, | |
| default: Date.now, | |
| }, | |
| updatedAt: { | |
| type: Date, | |
| default: Date.now, | |
| }, | |
| } | |
| ); | |
| // DSL 文件 Schema - 修改以存储文本内容 | |
| const dslFileSchema = new mongoose.Schema( | |
| { | |
| name: { | |
| type: String, | |
| required: [true, '请输入文件名称'], | |
| trim: true, | |
| }, | |
| content: { // 添加: 存储 YAML 文本内容 | |
| type: String, | |
| required: [true, '请提供 YAML 内容'], | |
| }, | |
| mimeType: { | |
| type: String, | |
| default: 'application/x-yaml', | |
| }, | |
| uploadedAt: { | |
| type: Date, | |
| default: Date.now, | |
| }, | |
| } | |
| ); | |
| // 提示词组 Schema | |
| const promptGroupSchema = new mongoose.Schema( | |
| { | |
| name: { | |
| type: String, | |
| required: [true, '请输入提示词组名称'], | |
| trim: true, | |
| }, | |
| description: { | |
| type: String, | |
| trim: true, | |
| }, | |
| category: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: 'Category', | |
| }, | |
| prompts: [promptSchema], | |
| workflows: [String], | |
| dslFiles: [dslFileSchema], | |
| createdBy: { | |
| type: mongoose.Schema.Types.ObjectId, | |
| ref: 'User', | |
| }, | |
| }, | |
| { | |
| timestamps: true, | |
| } | |
| ); | |
| const PromptGroup = mongoose.model('PromptGroup', promptGroupSchema); | |
| module.exports = PromptGroup; |