''String' entity are not getting created when using mongoose.save() function

When I'm creating a new document, the String entities of my schemas are not getting created empty but the arrays are getting created.

userSchema
{
  name: String,
  array: [ String ]
}

When I'm using db.collection.save(document) the document which is getting created in the collection is


{
  array: [ String ]
}



Solution 1:[1]

array is created as an empty array with no values populated, for primitive values, we can't populate as there is no value to put there, try inserting values into the db it will show up.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Navitas28