-
Notifications
You must be signed in to change notification settings - Fork 127
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
timestamps support in embedded_schema #160
Comments
I realize this issue is really old, but it is still an issue which I assume is why it's still open. Since mongoldb_ecto 1.0 is in beta, I assume this is a bug that would need to be fixed before the final release. When using the |
@bdtomlin This is a good question! I'm not quite sure how that would be implemented, but my guess is it wouldn't be straightforward conceptually or technically and possibly impossible. Timestamps can be set on the root document whenever it's created/updated, but embedded documents don't have quite as clean of a lifecycle. For instance, I could insert a bunch of comments into a post document and then create the post -- what timestamp do the comments get? Is it the timestamp of when they were added to the post struct or when the post was inserted into the DB? In terms of implementation, my guess is the implementation of timestamps on the root document is straight forward (e.g. add a I'm going to close this for now as I don't see a path forward for this feature. However, if anyone has any ideas on how to implement this, I would welcome the PR and would love to hear ideas on how to make it happen! |
Mongoid handles this with what it calls cascading callbacks. That name gives a pretty decent hint of a way to handle it. https://docs.mongodb.com/mongoid/current/tutorials/mongoid-relations/#cascading-callbacks I will try to come back to this in the future, but I think it would help to leave it open so it still has visibility for me or anyone else who may need this feature and has some time to work on it. |
I wasn't able to get timestamps support in embedded_schema. In result timestamp fields are
nil
for all embedded documents but it works fine for regular documents. Do i miss something, is there a way to get timestamps support forembedded_schema
?The text was updated successfully, but these errors were encountered: