https://github.com/devinus/crude
https://github.com/devinus/crude
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devinus/crude
- Owner: devinus
- Created: 2013-01-02T22:32:41.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-03-01T16:28:06.000Z (over 13 years ago)
- Last Synced: 2025-02-12T03:48:07.660Z (over 1 year ago)
- Language: Elixir
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CRUDE (Create, Read, Update, Delete, Exists)
```elixir
defpersistable Post do
fields [:id, :title, :body]
on_create :do_create
on_read :do_read
on_update :do_update
on_delete :do_delete
defp do_create(post) do
:ets.insert_new(:posts, post)
end
defp do_read(id) do
:ets.lookup(:posts, id)
end
defp do_update(post) do
:ets.insert(:posts, post)
end
defp do_delete(id) do
:ets.delete(:posts, id)
end
end
post = Post.new
post = post.title("Kurt stinks").body("No, really. He does.")
post.save
```