angular / angular/angularfire

Is there a way of doing in v7 the createId() method which was on AngularFire < v7

オープン
#3,055 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る
comp: firestore type: RFC / discussion / question version: legacy (v7-v16)
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。