import { model, Schema, Types } from "mongoose"; export interface PostType { title: string; text: string; theme: string; city: string; date: Date | number; counts?: number; user?: Types.ObjectId | string; file?: Array; } const PostSchema = new Schema({ title: { type: String, required: true, }, text: { type: String, required: true, }, theme: { type: String, }, city: { type: String, }, user: { type: Schema.Types.ObjectId, ref: "User", }, date: { type: Date, default: Date.now(), }, counts: { type: Number, default: 0, }, file: [ { type: Schema.Types.ObjectId, ref: "FileInfo", }, ], }); export default model("Post", PostSchema);