firebase / firebase/firebase-admin-node

[FR]: Why FirestoreDataConverter does not have two generics?

未关闭
#2,194 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
type: feature request
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

**Is your feature request related to a problem? Please describe.**
Add new generics type for fromFirestore in FirestoreDataConverter.

**Describe the solution you'd like**

Hi, I have suggestion about type of FirestoreDataConverter.
Although QueryDocumentSnapshot has generics type, FirestoreDataConverter has no generics except T.
Colud you add generics type S for QueryDocumentSnapshot in "fromFirestore" ?

```
export interface FirestoreDataConverter {
/**
* Called by the Firestore SDK to convert a custom model object of type T
* into a plain Javascript object (suitable for writing directly to the
* Firestore database). To use set() with `merge` and `mergeFields`,
* toFirestore() must be defined with `Partial`.
*
* The `WithFieldValue` type extends `T` to also allow FieldValues such
* as `FieldValue.delete()` to be used as property values.
*/
toFirestore(modelObject: WithFieldValue): DocumentData;

/**
* Called by the Firestore SDK to convert a custom model object of type T
* into a plain Javascript object (suitable for writing directly to the
* Firestore database). To use set() with `merge` and `mergeFields`,
* toFirestore() must be defined with `Partial`.
*
* The `PartialWithFieldValue` type extends `Partial` to allow
* FieldValues such as `FieldValue.delete()` to be used as property values.
* It also supports nested `Partial` by allowing nested fields to be
* omitted.
*/
toFirestore(
modelObject: PartialWithFieldValue,
options: SetOptions
): DocumentData;

/**
* Called by the Firestore SDK to convert Firestore data into an object of
* type T.
*/
fromFirestore(snapshot: QueryDocumentSnapshot): T;
}
```

```
export class QueryDocumentSnapshot<
T = DocumentData
> extends DocumentSnapshot {
private constructor();

/**
* The time the document was created.
*/
readonly createTime: Timestamp;

/**
* The time the document was last updated (at the time the snapshot was
* generated).
*/
readonly updateTime: Timestamp;

/**
* Retrieves all fields in the document as an Object.
*
* @override
* @return An Object containing all fields in the document.
*/
data(): T;
}
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。