How to use the @google-cloud/firestore.Timestamp.fromDate function in @google-cloud/firestore

To help you get started, we’ve selected a few @google-cloud/firestore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uphy / firestore-seed / src / index.ts View on Github external
if (o instanceof ImageSeed) {
                    var bucket = admin.storage().bucket();
                    p.push(o.upload(bucket, parentDocID).then(url => {
                        filteredObject = url;
                    }));
                } else if (o instanceof DocumentRefSeed) {
                    filteredObject = firestore.collection(o.collection).doc(o.document);
                } else if (o instanceof SubcollectionSeed) {
                    const subcollectionRef = self.getCollection(firestore).doc(context.doc.id).collection(key!);
                    const subcollection = new CollectionSeed(o.docs, () => subcollectionRef);
                    filteredObject = DELETE;
                    context.postDocActions.push(() => subcollection.importDocuments(admin));
                } else if (o instanceof GeoPointSeed) {
                    filteredObject = new GeoPoint(o.latitude, o.longitude);
                } else if (o instanceof Date) {
                    filteredObject = Timestamp.fromDate(o);
                } else if (o instanceof Timestamp) {
                    filteredObject = o;
                } else if (o instanceof Array || o instanceof Object) {
                    filteredObject = o instanceof Array ? Array(o.length) : {};
                    for (let i in o) {
                        p.push(filterObject(context, i, o[i]).then(filteredChild => {
                            if (filteredChild !== DELETE) {
                                filteredObject[i] = filteredChild;
                            }
                        }));
                    }
                }
                return Promise.all(p).then(() => {
                    return new Promise((resolve, reject) => {
                        resolve(filteredObject);
                    });
github firebase / firebaseopensource.com / functions / src / github.ts View on Github external
return resp.map((release: any) => {
        return {
          org,
          repo,
          url: release.html_url,
          tag_name: release.tag_name,
          created_at: Timestamp.fromDate(new Date(release.created_at))
        };
      });
    });