post.model.ts 682 Bytes
Newer Older
Lee Soobeom's avatar
Lee Soobeom committed
1
2
import { Document, model, Schema, Types } from "mongoose";
import { Posting } from ".";
Kim, MinGyu's avatar
Kim, MinGyu committed
3

Lee Soobeom's avatar
Lee Soobeom committed
4
5
6
7
8
9
10
11
export interface PostType {
  title: string;
  text?: string;
  theme: string;
  city: string;
  user?: Types.ObjectId | string;
  date?: Date;
  counts?: number;
Lee Soobeom's avatar
.    
Lee Soobeom committed
12
13
}

Lee Soobeom's avatar
Lee Soobeom committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const PostSchema = new Schema<PostType>({
  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,
  },
Kim, MinGyu's avatar
Kim, MinGyu committed
40
41
});

Lee Soobeom's avatar
Lee Soobeom committed
42
export default model<PostType>("Post", PostSchema);