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});'' –