How to use the @google-cloud/firestore.Timestamp 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 GoogleCloudPlatform / serverless-photosharing-workshop / functions / image-analysis / nodejs / index.js View on Github external
// determining if the picture is safe to show
        const safeSearch = response.safeSearchAnnotation;
        const isSafe = ["adult", "spoof", "medical", "violence", "racy"].every(k =>
            !['LIKELY', 'VERY_LIKELY'].includes(safeSearch[k]));
        console.log(`Safe? ${isSafe}`);

        // if the picture is safe to display, store it in Firestore
        if (isSafe) {
            const pictureStore = new Firestore().collection('pictures');

            const doc = pictureStore.doc(filename);
            await doc.set({
                labels: labels,
                color: colorHex,
                created: Firestore.Timestamp.now()
            }, {merge: true});

            console.log("Stored metadata in Firestore");
        }
    } else {
        throw new Error(`Vision API error: code ${response.error.code}, message: "${response.error.message}"`);
    }
};
github 1amageek / pring-admin.ts / src / base.ts View on Github external
public value(): any {
        const values: DocumentData = this.rawValue()
        const updatedAt: (keyof DocumentData) = "updatedAt"
        const createdAt: (keyof DocumentData) = "createdAt"
        values[updatedAt] = this.updatedAt || FirebaseFirestore.Timestamp.fromDate(new Date())
        values[createdAt] = this.createdAt || FirebaseFirestore.Timestamp.fromDate(new Date())
        return values
    }
github 1amageek / pring-admin.ts / src / base.ts View on Github external
public value(): any {
        const values: DocumentData = this.rawValue()
        const updatedAt: (keyof DocumentData) = "updatedAt"
        const createdAt: (keyof DocumentData) = "createdAt"
        values[updatedAt] = this.updatedAt || FirebaseFirestore.Timestamp.fromDate(new Date())
        values[createdAt] = this.createdAt || FirebaseFirestore.Timestamp.fromDate(new Date())
        return values
    }
github 1amageek / pring-admin.ts / lib / base.js View on Github external
function isTimestamp(arg) {
    return (arg instanceof firebase.firestore.Timestamp) || (arg instanceof FirebaseFirestore.Timestamp);
}
exports.isTimestamp = isTimestamp;