I am trying to use upsert in MongoDB to update a single field in a document if found OR insert a whole new document with lots of fields. The problem is that it appears to me
MongoDB 2.4 has $setOnInsert
db.somecollection.update( {name: "some name"}, { $set: { "lastseen": "2012-12-28" }, $setOnInsert: { "firstseen": # set on insert, not on update } }, {upsert:true} )