I need to create a sequential integer id in mongo for a particular collection. The need arises from a requirement that I need to store these ids in different collection in an array. If I am storing it as Mongo's ObjectID then the array exceeds 16MB document size. So is it possible to create a sequential id starting from 1?
Asked
Active
Viewed 937 times
3
-
3This talks abut it http://stackoverflow.com/questions/14054384/is-it-bad-to-change-id-type-in-mongodb-to-integer/14058189#14058189 – Sammaye Jun 28 '15 at 20:09
-
2however if the array exceeds then you have a serious problem, most likely it wont work with incremental ids either since your array grows even more and then it reaches the limit again – Sammaye Jun 28 '15 at 20:12
-
I agree that reaching the document size limit even with objectID smells like bad architecture. Is there a way to break up that array to be in more than one collection maybe? – jzapata Jun 29 '15 at 01:13