Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
d6f9b468
Commit
d6f9b468
authored
Jul 07, 2022
by
Yoon, Daeki
😅
Browse files
기본값으로 버전키와 비밀번호 toJSON 으로 유저 모델에서 제외
parent
3085c95e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/models/user.model.ts
View file @
d6f9b468
...
@@ -12,16 +12,26 @@ const validateEmail = (email: string) => {
...
@@ -12,16 +12,26 @@ const validateEmail = (email: string) => {
return
re
.
test
(
email
);
return
re
.
test
(
email
);
};
};
const
schema
=
new
Schema
<
IUser
>
({
const
schema
=
new
Schema
<
IUser
>
(
email
:
{
{
type
:
String
,
email
:
{
rquired
:
true
,
type
:
String
,
unique
:
true
,
rquired
:
true
,
validate
:
[
validateEmail
,
"
이메일을 입력해주세요
"
],
unique
:
true
,
validate
:
[
validateEmail
,
"
이메일을 입력해주세요
"
],
},
name
:
{
type
:
String
},
password
:
{
type
:
String
,
required
:
true
,
select
:
false
},
role
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
"
Role
"
},
},
},
name
:
{
type
:
String
},
{
password
:
{
type
:
String
,
required
:
true
,
select
:
false
},
toJSON
:
{
role
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
"
Role
"
},
versionKey
:
false
,
});
transform
(
doc
,
ret
,
options
)
{
delete
ret
.
password
;
},
},
}
);
export
default
model
<
IUser
>
(
"
User
"
,
schema
);
export
default
model
<
IUser
>
(
"
User
"
,
schema
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment