defmodule Telepai.App.History do
attributes do
integer_primary_key(:id)
attribute :data, :string do
allow_nil?(false)
constraints(trim?: true, max_length: 5000, allow_empty?: false)
end
end
relationships do
has_many :bookmarks, Telepai.Users.Bookmark do
api(Telepai.Users)
# I have played with hardcoded filters, too.
# But of course I don't want it hardcoded in the end :)
# filter(expr(user_id == 1))
end
end
calculations do
# hardcoded again
calculate(:is_bookmarked, :term, expr(bookmarks.user_id == 1))
# Or even this, but this needs the hardcoded filter in the relationship
# calculate(:is_bookmarked, :term, expr(not is_nil(bookmarks)))
end
end
defmodule Telepai.App.History do
attributes do
integer_primary_key(:id)
attribute :data, :string do
allow_nil?(false)
constraints(trim?: true, max_length: 5000, allow_empty?: false)
end
end
relationships do
has_many :bookmarks, Telepai.Users.Bookmark do
api(Telepai.Users)
# I have played with hardcoded filters, too.
# But of course I don't want it hardcoded in the end :)
# filter(expr(user_id == 1))
end
end
calculations do
# hardcoded again
calculate(:is_bookmarked, :term, expr(bookmarks.user_id == 1))
# Or even this, but this needs the hardcoded filter in the relationship
# calculate(:is_bookmarked, :term, expr(not is_nil(bookmarks)))
end
end