avoid empty object/array creation
See original GitHub issueHi, I find in my documents some fields like:
...
my_array_of_obj_field: [{}],
my_obj_field: {},
my_str_field: "",
...
(the cause is angularjs in frontend that initializes the empty model)
what’s the best way to avoid storing of those fields?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top Results From Across the Web
How can I remove empty object in from an array in JS
You can use Array.prototype.filter to remove the empty objects before stringifying. JSON ...
Read more >477780 – Avoid creating an empty array via new Object[0];
I frequently see in our code base the creation of an empty array via new Object[0]; We should avoid this unnecessary object creation,...
Read more >Empty Arrays - MATLAB & Simulink - MathWorks
Once you assign a nonempty object to an array, all array elements must be nonempty objects. Note. A class constructor must avoid returning...
Read more >TypeError: Reduce of empty array with no initial value
The JavaScript exception "reduce of empty array with no initial value" occurs when a reduce function is used. Message. TypeError: Reduce of empty...
Read more >remove empty object from array of objects javascript - You.com
Note: To remove both empty objects and empty arrays from the array, you can shorten the comparison to Object.keys().length === 0, as arrays...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
[]
for you by default so you can do.push()
and such without explicitly creating the array. To shut this off, overwrite the default array default (requires mongoose 4.4.15 or higher)minimize
property, unless you explicitly setminimize: false
.required: true
and empty strings will no longer be allowed.The
undefined
tonull
is expected behavior unfortunately, see comments here. Will fix the lowercase issue.