SergejJurecko/erlmongo

Mongo custom _id

Closed this issue · 4 comments

Hi, me again...

About the custom _id, I found that only object id is allowed for _id while it should support other custom id. Example user can pass Mong:save("col", [{"_id", "1234567890"}, {"a", 1}]). At the moment it will be duplicated _id. As far as I know mongodb allow that rite?

Use a binary <<"_id">> and it will work.

It will become {<<"_id">>, {oid, <<"1234567890">>}} which is default object id with limited max length. What I'm trying to say is mongo allow you create your own id like {<<"_id">>, <<"1234567890">>}. From mongo console, oid will look like { "_id" : ObjectId("123456789") } and for the custom id { "_id" : "1234567890"}

Mong:save("col",[{<<"_id">>,"some string"}]). will save the _id as it should be, as the string "some string".

Ah got it, thanks a lot...didn't figure out that one..just some correction...it should be <<"_id">> instead of <<"id">>.

Mong:save("col",[{<<"_id">>,"some string"}]).

Thanks again...