数组库文档:
{_id: 1, usernames: [{name: 'jack',userId:'a'},{name:'tony',userId:'b'}]}
mongodb更新操作写法:
model.updateMany({'usernames.name': 'jack'}, {$set: {'usernames.$.name': 'john'}});
更新后:
{_id: 1, usernames: [{name: 'john',userId:'a'},{name:'tony',userId:'b'}]}