Created
September 25, 2019 20:17
-
-
Save anoochit/5295b676a11263d3bfca75fb5e9e1ee6 to your computer and use it in GitHub Desktop.
add-document-to-firestore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
admin | |
.firestore() | |
.collection("products") | |
.add({ | |
name: "BrowserTestProduct26", | |
createdAt: Date.now(), | |
createdBy: admin.firestore().doc(`profiles/${userRecord.uid}`), | |
isDeleted: false, | |
category: categories[Math.floor(Math.random() * categories.length)] | |
}) | |
.then(createdProduct => { | |
console.log("Successfully created new product:", createdProduct.id); | |
}) | |
.catch(error => { | |
console.log("Error creating test product:", error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment