Add MusicLibrary.Notes contex functions

This commit is contained in:
Claudio Ortolina
2025-09-07 12:10:39 +03:00
parent 55ab648b1c
commit 824517dcba
+24
View File
@@ -0,0 +1,24 @@
defmodule MusicLibrary.Notes do
alias MusicLibrary.Notes.Note
alias MusicLibrary.Repo
def get_note(entity, musicbrainz_id) do
Repo.get_by(Note, entity: entity, musicbrainz_id: musicbrainz_id)
end
def create_note(note, attrs) do
note
|> Note.changeset(attrs)
|> Repo.insert()
end
def update_note(note, attrs) do
note
|> Note.changeset(attrs)
|> Repo.update()
end
def change_note(note, attrs) do
Note.changeset(note, attrs)
end
end