convert-firebase-timestamp-3
v0.0.4
Published
Convert Firebase timestamps to js native date in fetched object
Downloads
2
Maintainers
Readme
Disclaimer
This is a fork of the original convert-firebase-timestamp library written by @peterkracik.
Everything has been created by the original contributor(s) except commit 4a395490 that fixes a minor bug.
Convert firebase timestamps
Script that converts firebase timestamp values to the JS date format
- converts each timestamp within a document (object), also inside its maps and array
- converts single value
- possible to call in rxjs pipe
How to use
document
return this.db.collection('my-collection').doc(id).snapshotChanges().pipe(
map(doc => convertTimestamps(doc.payload.data())
)
single value
return this.db.collection('my-collection').doc(id).snapshotChanges().pipe(
map(doc => {
const data = doc.payload.data();
data.date = convertTimestamp(data.date);
return data;
})
)
in pipe ! don't call it before map, the original document is too large to be convert and it will throw recursion exception
return this.db.collection('my-collection').doc(id)
.snapshotChanges().pipe(
map(doc => doc.payload.data()),
convertTimestampsPipe(),
);
)