db.FirstTry.update({"id":1},{$set:{"Name":"Selvah"}});
I am getting an error like this
{ "message" : "WriteError({'code':10003,'index':0,'errmsg':'Cannot change the size of a document in a capped collection: 72 != 71','op':{'q':{'id':1},'u':{'$set':{'Name':'Selvah'}},'multi':false,'upsert':false}})", "stack" : "script:1:55" + "script:1:13" }
The size of the document in a capped collection is fixed, so you cannot insert a new field into the document. You will have to create a new temp collection and copy all data from old collection to new collection and add new field.
Something like this:
db.createCollection( "logItems_temp", { capped: true, size: 100000 } )
var cur = db.logItems.find()
while (cur.hasNext()) {
logItem = cur.next();
if(logItem.name == null){
logItem.name = selvah;
}
db.logItems_temp.insert(logItem);
}
db.logItems.drop()
db.logItems_temp.renameCollection("logItems")