| const mongoose = require('mongoose'); |
| const Schema = mongoose.Schema; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| const promptGroupSchema = new Schema( |
| { |
| name: { |
| type: String, |
| required: true, |
| index: true, |
| }, |
| numberOfGenerations: { |
| type: Number, |
| default: 0, |
| }, |
| oneliner: { |
| type: String, |
| default: '', |
| }, |
| category: { |
| type: String, |
| default: '', |
| index: true, |
| }, |
| projectIds: { |
| type: [Schema.Types.ObjectId], |
| ref: 'Project', |
| index: true, |
| }, |
| productionId: { |
| type: Schema.Types.ObjectId, |
| ref: 'Prompt', |
| required: true, |
| index: true, |
| }, |
| author: { |
| type: Schema.Types.ObjectId, |
| ref: 'User', |
| required: true, |
| index: true, |
| }, |
| authorName: { |
| type: String, |
| required: true, |
| }, |
| }, |
| { |
| timestamps: true, |
| }, |
| ); |
|
|
| const PromptGroup = mongoose.model('PromptGroup', promptGroupSchema); |
|
|
| const promptSchema = new Schema( |
| { |
| groupId: { |
| type: Schema.Types.ObjectId, |
| ref: 'PromptGroup', |
| required: true, |
| index: true, |
| }, |
| author: { |
| type: Schema.Types.ObjectId, |
| ref: 'User', |
| required: true, |
| }, |
| prompt: { |
| type: String, |
| required: true, |
| }, |
| type: { |
| type: String, |
| enum: ['text', 'chat'], |
| required: true, |
| }, |
| }, |
| { |
| timestamps: true, |
| }, |
| ); |
|
|
| const Prompt = mongoose.model('Prompt', promptSchema); |
|
|
| promptSchema.index({ createdAt: 1, updatedAt: 1 }); |
| promptGroupSchema.index({ createdAt: 1, updatedAt: 1 }); |
|
|
| module.exports = { Prompt, PromptGroup }; |
|
|