Initial commit

This commit is contained in:
2026-03-05 16:46:38 +07:00
commit 112e8604e2
124 changed files with 14369 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import mongoose, { Schema, Document } from "mongoose"
export interface IChapter extends Document {
novelId: string // Trỏ tới ID trong PostgreSQL
number: number
title: string
content: string
views: number
createdAt: Date
}
const ChapterSchema: Schema = new Schema({
novelId: { type: String, required: true, index: true },
number: { type: Number, required: true },
title: { type: String, required: true },
content: { type: String, required: true },
views: { type: Number, default: 0 },
createdAt: { type: Date, default: Date.now },
})
ChapterSchema.index({ novelId: 1, number: 1 }, { unique: true })
export const Chapter = mongoose.models.Chapter || mongoose.model<IChapter>("Chapter", ChapterSchema)