-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Hi @zookzook, thanks one more time for maintaining this library and merging my contributions!
I'm not sure yet what's the use for the types when defining a module with use Mongo.Collection
. Is it just for documentation/humans?
There doesn't seem to be any form of validation, nor does it seem to influence the default encoding/decoding process (and I'm okay with that).
Nonetheless, I noticed that calling SomeCollection.__collection__(:types)
includes some info about a document attribute set with embeds_many
, but missed a similar attribute set with embeds_one
.
elixir-mongodb-driver/lib/mongo/collection.ex
Lines 888 to 894 in 6071f18
@doc """ | |
Adds the struct to the `embeds_one` list. | |
""" | |
def __embeds_one__(mod, name, target, opts) do | |
Module.put_attribute(mod, :embed_ones, {name, target, add_name(mod, opts, name)}) | |
end | |
elixir-mongodb-driver/lib/mongo/collection.ex
Lines 905 to 911 in 6071f18
@doc """ | |
Adds the struct to the `embeds_many` list. | |
""" | |
def __embeds_many__(mod, name, target, type, opts) do | |
Module.put_attribute(mod, :types, {name, type}) | |
Module.put_attribute(mod, :embed_manys, {name, target, add_name(mod, opts, name)}) | |
end |
In embeds_many
the type is derived as type = unquote(Macro.escape({{:., [], [mod, :t]}, [], []}))
. I'm not sure what would be expected for the embeds_one
case, any advice?