라벨이 findByIdAndUpdate인 게시물 표시

[MongoDB] Mongoose(몽구스) findByIdAndUpdate, findOneAndUpdate 사용해서 documents field 값 업데이트하기

이미지
Video.js(model) const mongoose = require ( " mongoose " ) ; const Schema = mongoose . Schema ; const videoSchema = mongoose . Schema ( { writer : { type : Schema . Types . ObjectId , ref : " User " , }, nickname : { type : String , }, title : { type : String , maxlength : 50 , }, description : { type : String , }, genre : { type : String , }, cost : { type : Number , }, filePath : { type : String , }, views : { type : Number , default : 0 , }, duration : { type : String , }, thumbnail : { type : String , }, preview : { type : String , }, likes : { type : Number , default : 0 , }, }, { timestamps : true } ) ; const Video = mongoose . model ( " Video " , videoSchema) ; module.exports = { Video }; routes/video.js (rout...