Skip to content

Instantly share code, notes, and snippets.

@grant
Last active January 9, 2020 15:23
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 grant/22e37ee1534271208d83007aba69db39 to your computer and use it in GitHub Desktop.
Save grant/22e37ee1534271208d83007aba69db39 to your computer and use it in GitHub Desktop.
Cloud Run Storage – Firestore
// Create a Firebase client
const admin = require('firebase-admin');
admin.initializeApp({
credential: admin.credential.applicationDefault()
});
const db = admin.firestore();
async function uploadDoc(req, res) {
// Create a reference to the shoes doc.
let shoesDoc = db.collection('products').doc('shoes');
// Add a shoe
shoesDoc.set({
name: 'gshoe',
size: 11.5,
colors: ['blue', 'red', 'yellow', 'green']
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment