SergejJurecko/erlmongo

How to use Object IDs

Closed this issue · 4 comments

tgrk commented

Hello,

is it possible to use ObjectIDs(http://www.mongodb.org/display/DOCS/Object+IDs) as datatype for my collection? Thank you for this library and help.

Kind Regards,
tgrk

If you do a save, ObjectID will be created with: {oid, mongodb:create_id()}
You can do that yourself as well.

tgrk commented

Ok and in case if I want to save a reference (as ObjectID) from one collection to another collection? I am assuming that it is better practise (eg.performance, design) than using string type as reference. My idea is to create standard collection and link it with my file in GridFS using docid.

Regards,
tgrk

You can store {oid,ObjectID} in other collections sure.

tgrk commented

Thank you for your quick reply! It is obvious usage it this way in Erlang... I will think twice next time ;)