Commit d6f9b468 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

기본값으로 버전키와 비밀번호 toJSON 으로 유저 모델에서 제외

parent 3085c95e
......@@ -12,7 +12,8 @@ const validateEmail = (email: string) => {
return re.test(email);
};
const schema = new Schema<IUser>({
const schema = new Schema<IUser>(
{
email: {
type: String,
rquired: true,
......@@ -22,6 +23,15 @@ const schema = new Schema<IUser>({
name: { type: String },
password: { type: String, required: true, select: false },
role: { type: Schema.Types.ObjectId, ref: "Role" },
});
},
{
toJSON: {
versionKey: false,
transform(doc, ret, options) {
delete ret.password;
},
},
}
);
export default model<IUser>("User", schema);
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