-
Notifications
You must be signed in to change notification settings - Fork 8
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
Save and find nested entities #37
Save and find nested entities #37
Conversation
…d undefined handling collectionFieldsWithValues method modified to work with nested entities, filter null and undefined extracted to a method. collectionFields method modified to not remove entities
…ntities Tests for the modifications to the collectionFieldsWithValue and collectionFields methods, which now do not remove nested entities.
Adjust buildProxy to not return undefined when isEntity is true
Validates that fields are being converted to entities when they are nested.
An object passed to arrayDataParse can be null or undefined, so checking has been improved using the checker.
Adjust unit tests referring to entity array when value is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add tests in testDB folder before the full review
Maps the entity's internal fields and returns an object with these fields filled in.
Adds and Modifies existing tests to validate nested entities.
Codecov Report
@@ Coverage Diff @@
## main #37 +/- ##
==========================================
+ Coverage 94.50% 95.81% +1.31%
==========================================
Files 3 3
Lines 182 239 +57
==========================================
+ Hits 172 229 +57
Misses 10 10
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Valid, added tests referring to nested entities in the findById file. |
…efined Extract filter of null and undefined to `isNotNullOrUndefined` Refactor and change name of `filterNullAndUndefined` function Update `collectionFieldsWithValue` to use new function structure
Segregate entity parsing logic into `parseEntity` function
Must contain a children key containing an array of files when the field is entity
Recursion makes it possible to work with entities nested at multiple levels
Recursive parsing of nested entities allows multi-level nested objects to be parsed from the collection
Must be able to return an array of nested entities with multiple fields
adcc9cb
to
3896da7
Compare
When entity.type is an array, it must check if the item inside the array is an entity (extends BaseEntity)
🎉 This PR is included in version 4.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This pull request aims to implement a feature that will allow inserting and finding entities that contain fields that are entities (or array of entities), which in this context, I called nested entities.
This is related to issue #35
I also added export DataMapper class in Herbs2Mongo.js to allow developer to extend this class and create their own custom DataMapper.
I'm already covering a previous case reported in the issue, in which the collection was missing in the database containing the
meta
field that is inherited from BaseEntity, however, I'm not covering theerrors
field, which for now can be covered by developers simply doing a delete on the object before calling the find method, as this is a feature that will be addressed in the issue: herbsjs/gotu#71These changes do not implement breaking changes.
Proposed Changes
Screenshots
Nested entity in find method return:
Nested entity that was saved to the database:
Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance