Empty array is saved when a property references a schema
See original GitHub issuevar FooSchema = new Schema({});
var Foo = mongoose.model("Foo", FooSchema);
var BarSchema = new Schema({
foos: [Foo.schema]
});
var Bar = mongoose.model("Bar", BarSchema);
var b = new Bar();
b.save();
That will create an empty array of b.foos instead of just leaving the property undefined.
Issue Analytics
- State:
- Created 11 years ago
- Reactions:1
- Comments:39 (2 by maintainers)
Top Results From Across the Web
How to save an empty array as property of a nested object in ...
The usual request is to "supress" that. If you get no array, then your schema is not actually what you think it is....
Read more >empty - Manual - PHP
I'm summarising a few points on empty() with inaccessible properties, in the hope of saving others a bit of time. Using PHP 5.3.2....
Read more >Configuring the Map policy in the user interface - IBM
If you select Object or Array, you can create a schema through the user interface after you have clicked Done and returned to...
Read more >Work with arrays | BigQuery - Google Cloud
Flattening arrays with a CROSS JOIN excludes rows that have empty or NULL arrays. ... In this example, each value pair is stored...
Read more >Semi-structured Data Types - Snowflake Documentation
We often refer to these data types as semi-structured data types. ... the first of which is an empty ARRAY, and the second...
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 FreeTop 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
Top GitHub Comments
@antonioaltamura I forgot about this issue, the below works in mongoose 4.6:
Sorry, but this is a horrible design. You should not be deciding on my behalf wether I want it to be an empty array or not set at all. At least provide an option to disable this feature.