Skip to content

Instantly share code, notes, and snippets.

@anoochit
Created September 25, 2019 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoochit/5295b676a11263d3bfca75fb5e9e1ee6 to your computer and use it in GitHub Desktop.
Save anoochit/5295b676a11263d3bfca75fb5e9e1ee6 to your computer and use it in GitHub Desktop.
add-document-to-firestore
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