을 존재하지 않을 경우 0으로 설정. 문서에는 고유 한 ID, 마지막 액세스 시간을 저장하는 lastAccess 필드 및 문서 생성시 0으로 설정하고 업데이트하는 경우 1 씩 증가해야하는 timesAccessed 필드가 있습니다., MongoDB를 사용하여 문서를 Upserting 필드를 증가 내가 모음에서 문서를 upsert하는 Node.js를</p> <p>내가하고 싶은 것은에서 MongoDB를 사용하고
// coll is a valid collection
coll.update(
{user: accountInfo.uid},
{user: accountInfo.uid,
lastAccess: new Date(),
$inc: {timesAccessed: 1},
$setOnInsert: {timesAccessed: 0}
},
{upsert: true, w: 1},
function(err, result) {
if (err) throw err;
console.log("Record upserted as " + result);
});
을하지만, 노드는 말한다 :
나는 시도
MongoError: Modifiers and non-modifiers cannot be mixed
은 무엇 coincise하고 안전한 방법은이 작업을 수행하는 것입니다?