1.0.4 • Published 3 years ago

firestore-timestamp-formatter v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

firestore-timestamp-converter

NPM version

Firestore WithConverter method to auto convert from default firestore timestamp to javascript date object

Description

While working on a firestore project, I figured I needed to manually convert the firestore timestamp response to actual javascript date object before they become usable, the problem with this is that even if I have an array of data, I need to always loop through and manually convert to javascript date object using the toDate method. This can be time-consuming.

How To Use

import TimestampConverter from 'firestore-timestamp-formatter';

const response = await db
  .collection("user")
  .doc(id)
  .withConverter(TimestampConverter))
  .get();

The `response` will now contain a valid javascript date object instead of the default firestore timestamp.

Installation

Use your favourite package manager to add the package to your package.json

npm i firestore-timestamp-formatter
1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago