new RegExp(`^(?!.*${nickname}).*[A-Za-z0-9]{4,}$`);
// nickname 문자열을 포함하지 않으면서 [A-Za-z0-9]{4,} 배열안의 문자가 4개 이상
const rename = users.map(({_id,name,ID,pw}) => {
return {userId:_id, name:name,ID:ID,pw:pw}
})
find(), findOne()
find() 메서드는 배열로서 값을 반환함에 유의하자
mongodb virtual메서드 사용
postsSchema.virtual("postId").get(function () {
return this._id.toHexString();
});
postsSchema.set("toJSON", {
virtuals: true,
transform: function (doc, ret) {
delete ret._id;
delete ret.id;
},