Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Functional Programming
Diskuy-Backend
Commits
96a396ff
Commit
96a396ff
authored
Feb 08, 2021
by
Muhammad Rafif Elfazri
Browse files
Create seeds for dev
parent
f48013bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
priv/repo/seeds.exs
View file @
96a396ff
...
...
@@ -10,23 +10,25 @@
# We recommend using the bang functions (`insert!`, `update!`
# and so on) as they will fail if something goes wrong.
alias
Diskuy
.
Repo
alias
Diskuy
.
Account
.
User
alias
Diskuy
.
Forum
.
Topic
alias
Diskuy
.
Forum
.
Thread
alias
Diskuy
.
Forum
alias
Diskuy
.
Account
# Repo.insert!(%User{
# username: "rafif",
# email: "rafif@gmail.com"
# })
# Repo.insert!(%Topic{
# name: "Gaming",
# })
# Repo.insert!(%Thread{
# title: "Klee Gaming",
# points: 0,
# topic_id: "86284ef4-a22e-4c4b-8e46-212fa8a7a3f3",
# user_id: "rafif@gmail.com"
# })
{
:ok
,
user
}
=
Account
.
create_user
(%{
"username"
=>
"admin"
,
"email"
=>
"admin@gmail.com"
,
"picture"
=>
"None"
})
{
:ok
,
topic
}
=
Forum
.
create_topic
(%{
"name"
=>
"random"
})
Enum
.
each
(
0
..
200
,
fn
(
_x
)
->
Forum
.
create_thread
(
%{
"title"
=>
:crypto
.
strong_rand_bytes
(
32
)
|>
Base
.
encode64
|>
binary_part
(
0
,
32
),
"points"
=>
0
,
"content"
=>
:crypto
.
strong_rand_bytes
(
32
)
|>
Base
.
encode64
|>
binary_part
(
0
,
32
),
"topic_id"
=>
topic
.
id
,
"user_id"
=>
user
.
id
}
)
end
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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