show only your gists

This commit is contained in:
zack 2024-10-26 22:44:11 -04:00
parent b2f2f57029
commit 221c3ae76c
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
2 changed files with 8 additions and 2 deletions

View file

@ -6,6 +6,7 @@ defmodule Zoeyscomputer.Gists do
import Ecto.Query, warn: false
alias Zoeyscomputer.Repo
alias Zoeyscomputer.Users.User
alias Zoeyscomputer.Gists.Gist
@doc """
@ -21,6 +22,12 @@ defmodule Zoeyscomputer.Gists do
Repo.all(Gist)
end
def list_gists_for_user(%User{} = user) do
Gist
|> where([a], a.author_id == ^user.id)
|> Repo.all()
end
@doc """
Gets a single gist.
@ -52,7 +59,6 @@ defmodule Zoeyscomputer.Gists do
def create_gist(user, attrs \\ %{}) do
IO.puts("hereo")
attrs = Map.put(attrs, "author_id", user.id)
IO.inspect(attrs)
%Gist{}
|> Gist.changeset(attrs)