Not getting data of newly added array field

Hey, does anyone know how to add new fields to existing schemas properly? Because I added a new field with is an objectarray and I already saved some data to it which I checked in the mongodbCompass and it worked. But when trying to get the data unsing findOne, I get the document as before but the new field is an empty array and when trying to console.log only the array, it is undefined.... Anyone any idea?
1 Reply
Skylark
Skylark12mo ago
Add the new field and then you need to go through the entries to see if it has the field and if it doesn’t to add a value Or leave it and in the future if the field doesn’t exist provide a default value, there’s no point saving default values that can be generated easily. Although that doesn’t necessarily apply to you right now, I don’t know
Want results from more Discord servers?
Add your server