quazar
Why store ecto_arc field in database?
I am little bit confused about arc and ecto_arc using with phoenix. Suppose I have a schema “User” and it has avatar pic. Do I really need to create avatar string field or can I just get away with naming file consistently using id or uuid, ex.
def filename(version, {_, scope}) do
"avatar_#{scope.uuid}"
end
def storage_dir(version, {file, scope}) do
"uploads/images/#{scope.uuid}/"
end
It works but I am not sure it its best pratice. Also I have added boolean column (avatar_uploaded) to track if avatar is uploaded. I understand that boolean uses very few bytes compared to storing string and for a model with like million records this can really save some space. So should I do it? What pitfalls am I digging for myself?
Most Liked
NobbZ
String fields in a database, null or with a value, might still occupy the full space on disk that is defined as max. This is sometimes done by the DBMS as a measure of optimization (alignment of data on disk). Therefore usually just making the string fields nullable and treating null as nothing uploaded is probably the way that consumes the least space.







