Posts

Showing posts with the label Bitarray

Auto Increment In MongoDB To Store Sequence Of Unique User ID

Answer : As selected answer says you can use findAndModify to generate sequential IDs. But I strongly disagree with opinion that you should not do that. It all depends on your business needs. Having 12-byte ID may be very resource consuming and cause significant scalability issues in future. I have detailed answer here . You can, but you should not https://web.archive.org/web/20151009224806/http://docs.mongodb.org/manual/tutorial/create-an-auto-incrementing-field/ Each object in mongo already has an id, and they are sortable in insertion order. What is wrong with getting collection of user objects, iterating over it and use this as incremented ID? Er go for kind of map-reduce job entirely I know this is an old question, but I shall post my answer for posterity... It depends on the system that you are building and the particular business rules in place. I am building a moderate to large scale CRM in MongoDb, C# (Backend API), and Angular (Frontend web app) and fou...