1 回答
TA贡献1725条经验 获得超7个赞
更新数组字段使用$push关键词提供参考代码:使用node.jsvar filter;if (paramtype === 1) { filter = {helpapiuuid: helpapiuuid, "requests.paramid": opts.paramid};} else { filter = {helpapiuuid: helpapiuuid, "responses.paramid": opts.paramid};}var update;if (paramtype === 1) { update = { $set: { "requests.$.param": opts.param, "requests.$.type": opts.desc, "requests.$.desc": opts.desc, "requests.$.default": opts.default } };} else { update = { $set: { "responses.$.param": opts.param, "responses.$.type": opts.desc, "responses.$.desc": opts.desc, "responses.$.default": opts.default } };}return publicdb.collection(colname).findOneAndUpdateAsync(filter, update, {upsert: false})
- 1 回答
- 0 关注
- 1095 浏览
添加回答
举报