我正在制作一个分析系统,该API调用将提供一个唯一的用户ID,但顺序不正确且稀疏.
I am making a analytics system, the API call would provide a Unique User ID, but it's not in sequence and too sparse.
我需要给每个唯一用户ID一个自动增量ID,以在位阵列/位集中标记分析数据点.因此,第一个用户遇到的将对应于位数组的第一位,第二个用户遇到的将是位数组中的第二位,依此类推.
I need to give each Unique User ID an auto increment id to mark a analytics datapoint in a bitarray/bitset. So the first user encounters would corresponding to the first bit of the bitarray, second user would be the second bit in the bitarray, etc.
那么在MongoDB中是否有可靠且快速的方法来生成增量的唯一用户ID?
So is there a solid and fast way to generate incremental Unique User IDs in MongoDB?
推荐答案可以,但不能 web.archive/web/20151009224806/docs.mongodb/manual/tutorial/create-an-auto-incrementing-field/
mongo中的每个对象都已经有一个ID,并且可以按插入顺序对其进行排序.获取用户对象集合,对其进行迭代并将其用作增量ID有什么问题?完全去从事地图减少工作
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
更多推荐
在MongoDB中自动递增以存储唯一用户ID的序列
发布评论