db.col.insert({
name: 'kad',
tags: ['mongodb', 'database', 'NoSQL'],
})
I now have new data’ mysql’ to be added to the array corresponding to tags. How can I push it in?
Db.col.update ({'name':' kad'}, {$ set: {'tags':' MySQL'}}}) is it not equivalent to overwriting the original data
I want the result to betags:['mongodb','database','NoSQL','mysql']
Please refer to
db.col.update({name : "kad"}, { $push : { tags : "mysql"}})
Please also refer to official documents:
https://docs.mongodb.com/manu …
Suggestion: Read MongoDB documents more; MongoDB’s documentation is of high quality.