MongoDB adding data to Collections without an _id field?

Nevermind, found the answer to this on the official forums, for further reference I'll leave the final answer that I got from there NOTE: This answer supposedly works according to the mongoDB devs, however, I have not been able to get it to work properly, use at your own discretion and if something wrong happens, well, join in on the bug report fun! To be able to add documents to a collection without an "_id" field, first we need to create a Capped Collection, this Capped Collection (supposedly and according to the documentation, also, these collections require a max size to be set) gets documents added without an "_id" field by default, in some circumstances however, they might get the "_id" field added anyway, in this case we specify "autoIndexId" as false, this (supposedly) overwrites any defaults and sets the collection to not set the "_id" field as an index, allowing us later on to delete it so, to recap, step 1: we created a Capped Collection: db. CreateCollection("cappedcoll", {capped:true, size:100000}) step2: test the collection to check if it is indeed generating an "_id" field if it doesn't generate.

Why, you're luck! Congrats! If it does generate.

Step 3: we create a Capped Collection with the autoIndexId field set to false: db. CreateCollection("cappedcoll", {capped:true, size:100000, autoIndexId:false}) step4: we add an item to the collection and then we remove the "_id" field through an update: db.cappedcoll. Insert({"names": {"First": "Gonza", "Last": "Vieira"}}); db.cappedcoll.

Update({"names. First": "Gonza"},{$unset: {"_id":1}}) if you reach this part, then it either worked or you got a nasty cannot modify "_id error message, which shouldn't show up, since we set "_id" to not be the index of the collection And this also means you're exactly at the same stage as where I am Good luck, and I hope they either fix this soon, or someone here complements this post and corrects anything that I've said wrong.

Nevermind, found the answer to this on the official forums, for further reference I'll leave the final answer that I got from there. NOTE: This answer supposedly works according to the mongoDB devs, however, I have not been able to get it to work properly, use at your own discretion and if something wrong happens, well, join in on the bug report fun! To be able to add documents to a collection without an "_id" field, first we need to create a Capped Collection, this Capped Collection (supposedly and according to the documentation, also, these collections require a max size to be set) gets documents added without an "_id" field by default, in some circumstances however, they might get the "_id" field added anyway, in this case we specify "autoIndexId" as false, this (supposedly) overwrites any defaults and sets the collection to not set the "_id" field as an index, allowing us later on to delete it.So, to recap, step 1: we created a Capped Collection: db.

CreateCollection("cappedcoll", {capped:true, size:100000}); step2: test the collection to check if it is indeed generating an "_id" field. If it doesn't generate. Why, you're luck!

Congrats! If it does generate. Step 3: we create a Capped Collection with the autoIndexId field set to false: db.

CreateCollection("cappedcoll", {capped:true, size:100000, autoIndexId:false}); step4: we add an item to the collection and then we remove the "_id" field through an update: db.cappedcoll. Insert({"names": {"First": "Gonza", "Last": "Vieira"}}); db.cappedcoll. Update({"names.

First": "Gonza"},{$unset: {"_id":1}}); if you reach this part, then it either worked or you got a nasty "cannot modify "_id"" error message, which shouldn't show up, since we set "_id" to not be the index of the collection... And this also means you're exactly at the same stage as where I am. Good luck, and I hope they either fix this soon, or someone here complements this post and corrects anything that I've said wrong.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions