Answer the question
In order to leave comments, you need to log in
How to modify Mongoose array without strict: false?
An incomprehensible situation. I get data from Monga
I get an array with objects. Next, I need to modify each object in the array by adding a field to it. Seems like a simple task, but it doesn't work, the field is not added.const tweets = await Tweet.find({author}).exec()
const proceedTweets = tweets.map(tweet => {
Object.assign(tweet, {extra: 'stuff'})
return tweet
})
Answer the question
In order to leave comments, you need to log in
const proceedTweets = tweets.map(tweet => ({ ...tweet, extra: 'stuff' }));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question