-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate Collection with Ecto.Changeset? #4
Comments
Could someone help me understand why we're storing the type information like this? https://github.com/zookzook/yildun/blob/master/lib/yildun/collection.ex#L661 Here's what I'm trying to accomplish ... in order to use In my embeds_many :enrollments, Photon.Registrar.Enrollment, default: [] Then I can use the [
enrollments: {{:., [],
[
{:__aliases__, [counter: {Photon.Registrar.Cohort, 14}, line: 28],
[:Photon, :Registrar, :Enrollment]},
:t
]}, [], []},
updated_at: :utc_datetime,
inserted_at: :utc_datetime,
id: :string,
_id: {{:., [], [{:__aliases__, [alias: false], [:BSON, :ObjectId]}, :t]}, [],
[]}
] I'm not quite sure what to do with that Ultimately, what I think I'm looking for is a map that comes out looking like this: [
enrollments: Photon.Registrar.Enrollment,
updated_at: :utc_datetime,
inserted_at: :utc_datetime,
id: :string,
_id: BSON.ObjectId
] Am I going about this the wrong way? Or missing something super obvious? cc @zookzook |
Hi bryansray,
I'm sorry, but I would not integrate this library with Ecto.Changeset, because the Changeset does not work with documents in a really nice way. It is created for rows and tables, but if you try to use embedded documents like maps and arrays it is getting very complicated. For the most of my use cases I know what elements/attributes I will change, so I don't need to call some cast functions. Validation can be difficult and complex, so you always need to add some custom "cast" function and then, you providing a lot of workaround to get Changeset happy. |
It is a long time ago, since I wrote this library, but I try to remember. I guess, the specs are always written for AST. You never use it, it is just for the dializer. (This is a reason, why I don't care about the specs). The
and therefore it is expressed as AST. But I think, we can add a new function or change it. |
Apologies for placing this here ... it doesn't look like "Discussions" are enabled on this repo.
I was curious if anyone has had any success with integrating this library with
Ecto.Changeset
?I'm fairly certain that I could use Schemaless Changesets? But I'm just curious if anyone has gone down this rabbit hole before, before venturing into the great unknown. Or has had any success with any other solution I may not be thinking of? ✨
Thanks so much.
The text was updated successfully, but these errors were encountered: