MongoDB 如何将 object id 转换成顺序 id?

firsthym · August 31, 2012 · Last by chucai replied at August 31, 2012 · 3197 hits

什么意思?

url 里面我想显示的就是数字 1,users/1,而不是 mongodb 里面的 object id

MongoDB 的吗,ruby-china 用的这个 mongoid_auto_increment_id

用一个 gem 就可以了吗?

#4 楼 @firsthym 是啊,不过我觉得 UUID 也挺好的

那就先用着 object id 吧,看了一下有性能上的损失。

#6 楼 @firsthym 怎么个损失法?

ruby-china 那个 gem 里面有测试数据

@chinacheng mongo 官方“Generally in MongoDB, one does not use an auto-increment pattern for _id's (or other fields), as this does not scale up well on large database clusters. Instead one typically uses Object IDs.”,具体为什么影响 scale up,还不知。

恩。RubyChina 里有使用 Gem 的

You need to Sign in before reply, if you don't have an account, please Sign up first.