mongoDB 게시글에 시간 나타내기
server단 post 스키마에서 timestamps: true 설정하면 등록시간, 업데이트시간을 사용 가능합니다. timestamps: true const postSchema = new mongoose.Schema( { title: String, content: String, postNum: Number, image: String, author: { type: mongoose.Schema.Types.ObjectId, ref: "User", }, //댓글 갯수를 알기 위해서 repleNum 추가 repleNum: { type: Number, default: 0, }, }, { collection: "posts", timestamps: true } ); const Post = mongoose.model("..
2023. 6. 8.