Skip to content
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

Nested aka Sub-document entities with ID property not generating ID (ObjectId) on create #629

Open
taicho opened this issue Jun 7, 2021 · 4 comments
Labels

Comments

@taicho
Copy link

taicho commented Jun 7, 2021

Steps to reproduce

  1. Create an entity with an ID (ObjectId) property.
  2. Create another entity with an ID (ObjectId) property.
  3. Add a nested/sub-document property to the first entity referencing the second entity as the type; alternatively create an array of nested/sub-documents to the first entity referencing the second entity as the type.
  4. Create a new instance of the first entity and create and add an instance of the second entity to the first.
  5. Call save/create to persist to the database.

Current Behavior

  1. First entity will have an ObjectId automatically generated as is confirmed by inspection the record in the database.
  2. The child/nested/sub-document(s) (second entity) will have no ObjectId present in its ID property.

Expected Behavior

  1. First entity will have an ObjectId automatically generated as is confirmed by inspection the record in the database.
  2. The child/nested/sub-document(s) (second entity) would have an ObjectId present in its ID property that was automatically generated and should be the same for any further nested/sub-documents.

Additional information

Tested w/ 6.0.1.

I've used LB4 in several production applications so far and am a big proponent. That being said, this issue is severely hampering usage of MongoDB in real-world use cases where nested/sub-documents and nested/sub-document arrays are ever-present. Requiring workarounds by using juggler lifecycle events. Any attempt to resolve it is greatly appreciated. I also distinctly remember this working at one point and am not sure if this is a regression.

@taicho taicho added the bug label Jun 7, 2021
@taicho
Copy link
Author

taicho commented Jul 9, 2021

@bajtos or @dhmlau I wouldn’t typically reach out directly but I am attempting to use LB4 as the foundation for a large-scale product. I may attempt to resolve this issue myself but I could use input/guidance to make sure I am not oblivious to something that is known. On the surface it seems like the class for the nested/embedded document is never called implicitly as it on the parent by framework. The symptom mentioned above is that IDs and other properties with generated or default values residing on the embedded model are never populated. Any input would be useful at this point. Thanks in advance.

@stale stale bot added the stale label Sep 7, 2021
@achrinza achrinza removed the stale label Sep 7, 2021
@taicho
Copy link
Author

taicho commented Oct 26, 2021

Bump - still seeing this issue in latest.

@loopbackio loopbackio deleted a comment from stale bot Oct 26, 2021
@taicho
Copy link
Author

taicho commented Oct 13, 2022

Can I at least get a response from a core member of the team? Is this something known about but with no intention to change or is it a matter of bandwidth or possibly disputed? ObjectIds are still not generated for sub-document entities and this is widely used in production Mongo contexts.

@Nevoo
Copy link

Nevoo commented Oct 9, 2023

Would also be interested here. Or what an easy workaround could be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants