I am new to mongo and I want to use it in web application which has webform to edit relatively complex nested objects.
Long story short – I have editor written in JQuery/Knockout which generates proper json to save. If you saw video about knockout you can imaging how complex it could be.
My only problem that when I try to generate ID for object ob javascript side (for ObjectId property) it is ignored on deserialization (I am having “000000…00”)
I read about ObjectId specification http://www.mongodb.org/display/DOCS/Object+IDs and passing correct new id and trying to change last 3 bytes but it doesn’t work. Any ideas?
Currently I have something like:
function newMongoId() {
var id = settings.BaseId // fixed part (first 18 bytes) from server
+ settings.LastId++; // increment which starts from 100000
return { "$oid": id };
}
Well, that was issue with JavasriptSerializar which renamed all ‘Id’ property to ‘_id’.
After I assigned result of function above to _id all started to work fine