-
Notifications
You must be signed in to change notification settings - Fork 0
/
phoenix_notes.txt
42 lines (27 loc) · 1.11 KB
/
phoenix_notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Accessing database from command line
# get user with id = 2
iex> Discuss.Repo.get(Discuss.Discussions.User, 2)
[debug] QUERY OK source="users" db=8.2ms decode=1.7ms queue=1.0ms idle=150.6ms
SELECT u0."id", u0."email", u0."provider", u0."token", u0."inserted_at", u0."updated_at" FROM "users" AS u0 WHERE (u0."id" = $1) [2]
↳ anonymous fn/4 in :elixir.eval_external_handler/1, at: src/elixir.erl:298
%Discuss.Discussions.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
id: 2,
email: "tbarmann92@gmail.com",
provider: "github",
token: "ghu_endXE2FdGb5bYGLTiRAjemBTot2OOp3ubZiA",
topics: #Ecto.Association.NotLoaded<association :topics is not loaded>,
inserted_at: ~N[2022-10-15 01:46:51],
updated_at: ~N[2022-10-15 01:46:51]
}
Phoenix will not by default fetch associations
-----------------------------------------
Generate migration
iex> mix ecto.gen.migration add_comments
will generate migration, stored in `priv` folder
Run migration
iex> mix ecto.migrate
----------------------
Channels
in CommentsChannel module, join() is called whenever a javascript client
attempts to join this channel.