googleapis / googleapis/google-cloud-node

Global converters for different types

Open
#7,487 6 comments 3 reactions 1 assignee Claimed by @wu-hui View on GitHub
api: firestore library: nodejs-firestore type: feature request
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

The idea is to set global converters, maybe using
```typescript
admin.firestore().settings({
converters: []
})
```

That can be reused along with all the requests and for individual types, for example, for `Timestamp`:

I have many models where I use the Javascript Date object which gets converted to a `Timestamp` object, and when I get from the database, I cannot use `snapshot.data() as MyModel`, because if `MyModel` contains a Date property, it will be undefined since Timestamp cannot be converted directly to Date. This can be solved using a converter and `withConverter`, but it makes sense to have many converters only for a Date property? Why we can make it global using `FirestoreDataConverter` ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.