0
此Meteor服务器代码需要从字段找到的文档中除去“fName”以外的所有字段,并且如果文档不存在,则创建它。
有没有办法一次做到这一点? THX删除除mongodb文档以外的所有字段
myCol.update({fName: someName}, {fName: someName}); // works if doc exists, fails if no doc.
myCol.upsert({fName: someName}, {fName: someName}); // failed if doc exists, works if it exists
为什么你不试试在查询部分中的fName:{$ exists:true}? – Astro
thx。我用'myCol.upsert({fName:{$ exists:true}},{fName:someName});'' –