Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -25,5 +25,6 @@ const ChapterSchema: Schema = new Schema({
|
||||
})
|
||||
|
||||
ChapterSchema.index({ novelId: 1, number: 1 }, { unique: true })
|
||||
ChapterSchema.index({ createdAt: -1, novelId: 1 })
|
||||
|
||||
export const Chapter = mongoose.models.Chapter || mongoose.model<IChapter>("Chapter", ChapterSchema)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import mongoose, { Schema, Document } from "mongoose"
|
||||
|
||||
export interface IEditorRecommendation extends Document {
|
||||
novelId: string
|
||||
editorId: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
const EditorRecommendationSchema: Schema = new Schema(
|
||||
{
|
||||
novelId: { type: String, required: true, index: true },
|
||||
editorId: { type: String, required: true, index: true },
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
)
|
||||
|
||||
EditorRecommendationSchema.index({ novelId: 1, editorId: 1 }, { unique: true })
|
||||
EditorRecommendationSchema.index({ createdAt: -1 })
|
||||
|
||||
export const EditorRecommendation =
|
||||
mongoose.models.EditorRecommendation ||
|
||||
mongoose.model<IEditorRecommendation>("EditorRecommendation", EditorRecommendationSchema)
|
||||
@@ -0,0 +1,25 @@
|
||||
import mongoose, { Document, Schema } from "mongoose"
|
||||
|
||||
export interface IUserRecommendation extends Document {
|
||||
userId: string
|
||||
novelId: string
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
}
|
||||
|
||||
const UserRecommendationSchema: Schema = new Schema(
|
||||
{
|
||||
userId: { type: String, required: true, index: true },
|
||||
novelId: { type: String, required: true, index: true },
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
)
|
||||
|
||||
UserRecommendationSchema.index({ userId: 1, novelId: 1 }, { unique: true })
|
||||
UserRecommendationSchema.index({ createdAt: -1 })
|
||||
|
||||
export const UserRecommendation =
|
||||
mongoose.models.UserRecommendation ||
|
||||
mongoose.model<IUserRecommendation>("UserRecommendation", UserRecommendationSchema)
|
||||
Reference in New Issue
Block a user