angular / angular/angularfire

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

Đang mở
#3,055 7 bình luận 0 reaction 0 người được giao Xem trên GitHub
comp: firestore type: RFC / discussion / question version: legacy (v7-v16)
Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
22 giờ 28 phút
Pull request đã merge (30 ngày)
6

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với src/compat/firestore/firestore.ts tại phương thức createId() được liên kết, sau đó so sánh hành vi của nó với các entry point Firestore của AngularFire v7 và Firebase 9 được đề cập trong issue. Công việc được xem là hoàn tất khi đã xác định được phần thay thế được hỗ trợ hoặc đã ghi rõ ràng rằng không có phần thay thế nào.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
angular, typescript
Lĩnh vực
databases
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
50/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.