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
travel
Commits
0f75f3a8
Commit
0f75f3a8
authored
Jul 19, 2022
by
Yoon, Daeki
😅
Browse files
db 초기화
parent
39f40906
Changes
2
Hide whitespace changes
Inline
Side-by-side
migrations/create.admin.ts
0 → 100644
View file @
0f75f3a8
import
{
connect
}
from
"
mongoose
"
;
import
{
mongoUri
}
from
"
../src/config
"
;
import
{
Role
,
User
}
from
"
../src/models
"
;
import
{
userDb
}
from
"
../src/db
"
;
const
roles
=
[
[
"
admin
"
,
1
],
[
"
manager
"
,
10
],
[
"
staff
"
,
100
],
[
"
user
"
,
1000
],
[
"
guest
"
,
10000
],
];
connect
(
mongoUri
)
.
then
(
async
(
mongoose
)
=>
{
const
adminRole
=
await
Role
.
findOne
({
name
:
"
admin
"
});
await
userDb
.
createUser
({
email
:
"
admin@example.com
"
,
name
:
"
admin
"
,
role
:
adminRole
?.
_id
,
password
:
"
asdfasdf
"
,
});
await
mongoose
.
disconnect
();
})
.
catch
((
error
)
=>
console
.
log
(
"
롤 초기 생성 에러
"
,
error
));
migrations/create.roles.ts
0 → 100644
View file @
0f75f3a8
import
{
connect
}
from
"
mongoose
"
;
import
{
mongoUri
}
from
"
../src/config
"
;
import
{
Role
}
from
"
../src/models
"
;
const
roles
=
[
[
"
admin
"
,
1
],
[
"
manager
"
,
10
],
[
"
staff
"
,
100
],
[
"
user
"
,
1000
],
[
"
guest
"
,
10000
],
];
connect
(
mongoUri
)
.
then
(
async
(
mongoose
)
=>
{
const
retRoles
=
roles
.
map
(
async
([
name
,
priority
])
=>
{
const
result
=
await
Role
.
create
({
name
,
priority
});
return
result
;
});
try
{
await
Promise
.
all
(
retRoles
);
console
.
log
(
"
roles created successfully.
"
);
}
catch
(
error
)
{
console
.
log
(
"
error:
"
,
error
);
}
finally
{
await
mongoose
.
disconnect
();
}
})
.
catch
((
error
)
=>
console
.
log
(
"
롤 초기 생성 에러
"
,
error
));
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