Commit 0701dfb0 authored by Болатов Ален's avatar Болатов Ален

Merge branch '21' into 'dev'

some changes

See merge request !22
parents 4ba578d4 6e0a4fa8
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