mongodbmeteormeteor-collections

Need for change size of meteor collection _id


As we know .. Meteor collection after insert return a 16 char id, and that is too much for me. Can i change meteor collection _id generation to generate a 6 char id instead of 16 char ?


Solution

  • Yes, you can roll send your own _id with the insert and as long as it is unique, Mongo will accept:

    Mongo.insert({_id:'foobar'})

    So when you go to insert, just generate a random 6 digit string. You'll have to do your own checking to verify your generated _id is unique.