Is there a way of doing in v7 the createId() method which was on AngularFire < v7
- 主要語言
- TypeScript
- 星號
- 7.8k
- 分支
- 2.2k
- 平均合併
- 22 小時 28 分鐘
- 30 天內合併 PR
- 6
描述
Hi everyone,
I'm not sure this is a bug, but rather, it might bring to light a potential breaking change. Anyway, I'd be happy to be in the wrong concerning my issue. I also tried to search for this in Stackoverflow but I couldn't find anything related to my problem.
I upgraded one of my applications to AngularFire v7 (latest), not using the compat layer, but directly the new API approach. In the end, it seems to be easier to use and closer to the firebase API, and the use of RxFire seems quite straightforward.
In the process, I managed to rewrite all my API calls etc... Except for one thing: I didn't find a replacement method for the old `createId()` method that exists on v6.1.5, which is still present in the compat layer:
[createId()](https://github.com/angular/angularfire/blob/master/src/compat/firestore/firestore.ts#L246)
I paste the code here also so it's easier to read:
```
createId() {
return this.firestore.collection('_').doc().id;
}
```
I tried to implement it the same way in v7:
```
return doc(this.firestore, '_').id;
```
But this method is too naïve, and triggers some error:
```
ERROR FirebaseError: Invalid document reference. Document references must have an even number of segments, but _ has 1.
```
### Version info
**Angular: 12 **
**Firebase: 9**
**AngularFire: 7.1 **
### Expected behavior
The actual new API should provide a way to do the same functionality as v6.1.5. Maybe there's a way to do it but I couldn't find out what it is. If the API has no such functionality, it should be in the documentation somewhere, but again, I couldn' t find where.
### Actual behavior
The createId() method seems not reproduced with the new v7 API.
貢獻指南
研究方向
從 src/compat/firestore/firestore.ts 中連結的 createId() 方法開始,然後將其行為與 issue 中提到的 AngularFire v7 和 Firebase 9 Firestore 入口點進行比較。確定了受支援的替代方案,或明確記錄不存在替代方案,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- angular, typescript
- 領域
- databases
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 50/100