[FR] Algorithm for unique ID generation
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 22/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- firebase, nodejs, typescript
调研方向
从 Firestore 添加示例开始,审查关于在 beforeUserCreated 和 Firestore 阻塞函数中使用自定义 ID 的相关请求。明确范围涵盖 Authentication、Firestore 还是两者,然后在实现之前定义有序 ID、长度和字符规则以及服务器生成字段的验收标准。
由索引模型根据 Issue 内容生成。
描述
Is your feature request related to a problem? Please describe.
When there is a time we rely on firebase to generate unique ID for firestore or authentication, sometimes we don't want complete random ID. There should be some option to control the ID generation algorithm
I wish I could generate ID that can be always sorted. At least incremental or any monotonic function should be allow to prepend to the generated ID, such as base64 encoded unix timestamp
Additionally it should allow specifying the length of id, and the allowed encode character such as, is it case-sensitive, only numeric or alphanumeric, is it allow symbol, so on. So we have
Describe the solution you'd like
For authentication, maybe it could have option at the firebase console to specify the detailed algorithm as checkbox/radio
For firestore. Actually I wish I could have ability to do servervalue string formatting. So I could have firestore server generate any field, include ID, with the string I want
For this particular case I think we should have
db.collection("users").add({ // Should allow push new document with __name__ as id
"__name__": ServerValue.calculate("string(request.time.toMillis(),16).reverse() + hashing.crc32(request.path).toHexString()"), // use firebase rule syntax for server generate value
data : "anydata"
});
The above example generate reverse hex string from time and hash of the path. This function guaranteed incremental from server timestamp but also seemingly random at start and the end
(Also I want to request that string() function in firebase rule system should have base argument for int value, and also reverse function)
Describe alternatives you've considered
There is a request to allow set custom ID in beforeUserCreated as requested in https://github.com/firebase/firebase-tools/issues/5675
Same go for firestore blocking function https://github.com/firebase/firebase-admin-node/issues/2077
Additional context
Is it possible to have firebase server issue request in github too?
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 16
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-node 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 条评论 · 已指派 1 人 ·
-
api: messaging
难度 3/5 1-2 天 新手友好度 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
难度 5/5 一周以上 新手友好度 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 条评论 · 已指派 1 人 ·
查看 firebase/firebase-admin-node 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
bcgov/bc-wallet-mobile#4761 · 1 条评论 ·
-
external-issue to-triage
难度 2/5 1-3 小时 新手友好度 88/100
-
area-deployment area-integrations triage:bot-seen
难度 2/5 半天 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
refactor
难度 2/5 1-3 小时 新手友好度 84/100