In the back end i m using go lang and for database i use mongoDB. I m trying to find the last document inserted in the embedded array so i can retrieve the document in the last array index without knowing its index.Is is possible?? After researching on this i came to know that its not possible.So i m thinking of using $push,$each and $position.Here i can set the position to 0 so the newly added document will be in 0 so i can retreive it using the index 0. Here is my schema type ( Employee struct { EmpId string AualLeave []*AualLeaveInfo } AualLeaveInfo struct { ATotal int64
} I use the mgo statement as follows
c.Update(bson.M{"empid": "string"}, bson.M{"$push": bson.M{"aualleave":bson.M{"$each": bson.D{"atotal": 4},"$position":0}}}) please help me.Thanks..
