Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正如我们所知.. 插入后的 Meteor 集合返回一个 16 字符 id,这对我来说太多了。我可以更改流星集合 _id 生成以生成 6 char id 而不是 16 char 吗?
是的,您可以使用 发送您自己_id的insert,只要它是唯一的,Mongo 将接受:
_id
insert
Mongo.insert({_id:'foobar'})
因此,当您转到 时insert,只需生成一个随机的 6 位字符串。您必须自己检查以验证您生成_id的内容是唯一的。