some changes

parent 4ba578d4
import { Document, ObjectId } from "mongoose"; import {Document, ObjectId} from 'mongoose';
export default interface IPost extends Document { export default interface IPost extends Document {
_id: ObjectId _id: ObjectId;
title: string title: string;
description: string description: string;
image: File | undefined | string image: File | undefined | string;
datetime: Date datetime: Date;
user: ObjectId;
} }
import mongoose, { Schema } from "mongoose"; import mongoose, {Schema} from 'mongoose';
import IPost from "../interfaces/IPost"; import IPost from '../interfaces/IPost';
const PostsSchema: Schema = new Schema<IPost>({ const PostsSchema: Schema = new Schema<IPost>(
{
title: { title: {
type: String, type: String,
required: true required: true,
}, },
description: { description: {
type: String, type: String,
required: false
}, },
image: String, image: {
type: String,
},
datetime: { datetime: {
type: Date, type: Date,
default: Date.now() default: Date.now,
required: true,
},
user: {
type: Schema.Types.ObjectId,
required: true,
},
},
{
versionKey: false,
} }
}, { );
versionKey: false
})
export const Post = mongoose.model<IPost>('Post', PostsSchema) export const Post = mongoose.model<IPost>('Post', PostsSchema);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment