serverTimestamp fails when uploading to firestore.
- 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ả
Version info
Angular: ^17.3.0",
Firebase: 9.23.0
AngularFire: ^17.0.1",
Node v20.11.
How to reproduce these conditions
Failing test unit, Stackblitz demonstrating the problem:
Currently, I do not have a failing test unit or a Stackblitz example, but I can describe the issue and the steps to reproduce it below.
Steps to set up and reproduce:
Set up AngularFirestore and AngularFireStorage in your Angular component.
Create a form with a field set to serverTimestamp().
Attempt to update a Firestore document using WriteBatch.update() with the form values.
Here is a snippet of the code causing the issue:
```
import { serverTimestamp } from 'firebase/firestore';
import { AngularFirestore } from '@angular/fire/compat/firestore';
constructor(private afs: AngularFirestore, ...) {
this.form = this.builder.group({
dateReported: [serverTimestamp(), Validators.required],
...
});
const batch = this.afs.firestore.batch();
const orderRef = this.afs.firestore.collection(...).doc(....);
batch.update(orderRef, this.form.value);
batch.commit()
}
```
Sample data and security rules:
Please provide the necessary data structure and Firestore security rules if they are relevant to the issue.
Debug output
Errors in the JavaScript console:
```
{
"items": [
{
"sku": "2756",
"qty": 1,
"name": "\tImpresora Artillery X3 Plus"
}
],
"dateReported": {
"_methodName": "serverTimestamp"
},
"dateModified": {
"_methodName": "serverTimestamp"
},
"trialsAndResults": "cable suelto",
"inspectedItems": [
{
"sku": "2756",
"qty": 1,
"name": "\tImpresora Artillery X3 Plus",
"dictum": "repair"
}
],
"status": "examined",
"technician": "Cristobal",
"charge": 0,
"report": null
}
FirebaseError: Function WriteBatch.update() called with invalid data. Unsupported field value: a custom sl object (found in field dateReported in document [...])
```
Output from firebase.database().enableLogging(true);:
Please attach output if available.
Screenshots:
Please attach screenshots if they help illustrate the problem.
Expected behavior
The expected behavior is that the Firestore document should be updated with the current server timestamp in the dateReported field without any errors.
Actual behavior
The actual behavior is that an error is thrown when trying to update the Firestore document, indicating that an unsupported field value (a custom sl object) was found in the dateReported field.
Also there is no documentation how to use serverTimestamp, increment, etc, for current version using compat.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ AngularFirestore batch.update() được cung cấp với các phiên bản Angular, Firebase, AngularFire và Node được liệt kê. So sánh cách sử dụng compat của serverTimestamp và các giá trị trường liên quan với tài liệu hiện tại; công việc được xem là hoàn tất khi phần tái hiện được giải thích và cách sử dụng được hỗ trợ hoặc tài liệu cần thiết đã rõ ràng.
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, documentation
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100