Ecto.Association.NotLoaded
is a plain old simple struct, so you might relatively easy implement this unpreload
youself:
defmodule Unpreloader do
def forget(struct, field, cardinality \ :one) do
%{struct |
field => %Ecto.Association.NotLoaded{
__field__: field,
__owner__: struct.__struct__,
__cardinality__: cardinality
}
}
end
end
And use it later as:
Unpreloader.forget(%Post{....}, :comments)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…